is there any way, to output, like this:

echo $current_type;

and it gave me:

is_404() or is_page() or whatever it is_blabla()

  • Your question was flagged as "unclear what you are asking", and I cast my vote as such. As I asked in your previous question, what are you trying to achieve. As it stands, no one knows what your expected outcome is. Please file an edit and explain why you need to do this, what are you trying to achieve with the expected outcome – Pieter Goosen Sep 12 '14 at 7:55

is_404() and is_page() is simply just conditionals which just checks if a condition exists. Like is_404() simply checks if the current page is a 404 page and returns true on success and false on failure.

VERY IMPORTANT NOTICE: Conditional query tags do not work before the query is run. Before then, they always return false

You can get objects from the current page by just simply doing a var_dump on get_queried_object() like for example

 $queried_object = get_queried_object();
 var_dump( $queried_object );


All of these conditionals are set in the WP_Query class, and then separately wrapped in a function in wp-includes/query.php. For instance, is_404() is just a wrapper for $wp_query->is_404();

697 /**
698  * Is the query a 404 (returns no results)?
699  *
700  * @see WP_Query::is_404()
701  * @since 1.5.0
702  * @uses $wp_query
703  *
704  * @return bool
705  */
706 function is_404() {
707         global $wp_query;
709         if ( ! isset( $wp_query ) ) {
710                 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1' );
711                 return false;
712         }
714         return $wp_query->is_404();
715 }
  • and that's what i wanted, to get the string is_ABCD whatever is current object. thanks. – T.Todua Sep 1 '16 at 11:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.