Get Queried Object WordPress
WordPress has a built in handy function called get_queried_object(). Get queried object WordPress will allow you to get currently queried object. This is really valuable and beneficial if you’re familiar with functions, post types and taxonomies. These are outcomes of queried object.
- Single Post will return the post object
- Page will return the page object
- Archive page will return the post type object
- Category archive will return the category object
- Author archive will return the author object
For better understanding below is a Single Post queried object output. You can access anything in the object via queried object.
If you want to see the output of the function get_queried_object() just use the below code. I am including this code for newbies.
echo '<pre>'; print_r( get_queried_object() ); echo '</pre>'; die();
Please use die() function as your preference. I included it due to get clear output. Using die() you’ll not see rest of the content.
- get_queried_object_id wordpress
- get_queried_object taxonomy
- get queried object type
- get queried object name
- get_queried_object wordpress
- get_queried_object in wordpress
Hope you’ll enjoy this tutorial.