I’d like a way to target only blog-area pages for specific formatting.
So far,
<?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!!
Based on what you described:
And then just call the is_blog() function whenever needed.
I also found this, which looks like a more specific way to do the same thing https://gist.github.com/1189639
All the
is_*()
»Conditional Tags« are wrappers for theiris_*
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 alsois_post_type_archive()
to lock those out).is_home()
andis_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 pagesis_404()
catches everything … that wasn’t catchedSo 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.
bit more completed with PHP function would possible include strpos($_SERVER[‘REQUEST_URI’], “blog”)
final solution: