function to include is_home, is_archive, is_category, is_author etc in one function?

I’d like a way to target only blog-area pages for specific formatting.

So far,

Read More
<?php if (is_home() || is_single() || is_category() || is_archive() ) { ?>

works okay, but is there a way to combine all of those into one single function to shorten it up a bit? so maybe in the functions it would set is_blog() to equal those four (or however many I want).

Seems a bit simple and probably is…. I just dont know what to search for to find information on this. Thanks!!

Related posts

Leave a Reply

3 comments

  1. All the is_*() »Conditional Tags« are wrappers for their is_* pendants in the global $wp_query object. They all reflect parts of the »Template Hierarchy« which determines which file should be loaded (if present) to display the request.

    To make it short here’re the most general:

    • is_archive() covers all Tag, Taxonomy, Category, Post Type (Post/Page/Attachments/links/Custom Post Type, etc.) archive pages (there’s also is_post_type_archive() to lock those out).
    • is_home() and is_front_page() are basically the same, with the difference, that they distinguish the display setting for the front page: Latest posts & static front page.
    • is_singular() catches all “single” views, like a page, an attachment, a post, etc.
    • is_search() covers search result pages
    • is_404() catches everything … that wasn’t catched

    So based on this list, you should be able to wrape up what you need – depending what “blog area pages” are for you.


    As a little helper, you can use the functions from this answer that lists all conditionals that are true on a request. This should help you getting around it pretty quick.

    Just upload it as a plugin. Deactivate it when you’re done.

  2. bit more completed with PHP function would possible include strpos($_SERVER[‘REQUEST_URI’], “blog”)

    final solution:

        function is_blog()
        {
            return ( is_home() || is_single() || is_category() || is_archive() || strpos($_SERVER['REQUEST_URI'], "blog") );
        }