Conditions in WordPress

Many times I need to have a feedback about the WordPress conditions that are met on any particular page.

This comes handy when custom developing web sites. I called the function get_post_conditions(). What it does, it examines if WordPress conditions such as is_home, is_page, is_single, … are met.

/* call it anywhere and get the conditions set */

function get_post_conditions(){

	global $wp_query;		

	foreach (array('is_single','is_preview','is_page','is_archive','is_date','is_year','is_month','is_day','is_time','is_author','is_category','is_tag','is_tax','is_search','is_feed','is_comment_feed','is_trackback','is_home','is_404','is_comments_popup','is_admin','is_attachment','is_singular','is_robots','is_posts_page','is_paged') as $is) 

	{

		if ($wp_query->$is)

		{

Thanks "<pre>";

			print($is);

			echo "</pre>";

		}

	}

You can simple add this function to functions.php and call if from footer.php

The feedback you may get may look like this:

is_archive

is_category

Thanks.

tags: & category: -