Site icon League WP

Display Word Count in Post Info in Genesis

Back in the day when WordPress just was a blogging platform, text editor was the most component of the blogging software. WordPress has come a long way since those times but even today, quite a few bloggers are very particular about creating the right user experience. Therefore, you can see many blogs where the post info displays the average reading time, relative post time, and the word count.

When I Googled to find the solution for my project running on Genesis Framework, I didn’t find any information. After playing around with the code, I finally turned to Genesis WP ground on Facebook and I wasn’t disappointed, thanks to Victor Front and Sridhar Katakam.

Anyway, it’s time to stop ranting and start sharing the guide on how to display word count in post info in Genesis theme.

We basically achieve this by creating a function for word count calculation, a short code for the output and, then add the short code by using Genesis Filter for post info.

To begin with, add the following code to your functions.php.

Once you’re done with functions.php, you can see the word count populated in the post needs to stand out from the other pieces of information in the post info. Since there’s no class associated with a short code, you can’t really customize it. However, there’s a work word – you can create a -before/-after pseudo element to customize the classed used in other post info element such as author link, comments or post date.

In our case, we can use the following css code:


.entry-comments-link::before, .entry-time::after {
content: "\2014";
margin: 0 6px 0 2px;
}

That’s it – now refresh your page and the word count of your blog post will appear in the post info.

I hope you found this post helpful. If you have any questions, please let me know in the comments below.

Exit mobile version