WordPress is_post / is_single

Have you been trying to fix some function in wordpress theme or plugin which needs to see if the user is on a post page or not?

Well I’ve been trying that too! I was coding a function in my theme to check if the user is on a single post page or not. (by the way, in_post() is now deprecated in wordpress, instead use is_single() ).

So instead of using the function:

if(!is_page()) { }

why don’t we use:

if(is_single()) { }

Here’s the difference:

Time first one will be called if it’s category list or homepage too. Or anywhere you customize the $content for you (like custom excerpt length) and so on.

Let me know if you have any queries related to it.

Leave a Reply

Your email address will not be published.