I have a very simple plugin:
add_action('pre_get_posts', 'post_page');
function post_page()
{
global $wp_query;
if(is_category())
{
echo '<pre>';
print_r($wp_query);
exit;
}
}
I have to get the category ids within my plugin. I am getting without SEO urls but category__in is empty with SEO urls
Without SEO friendly url (category__in not empty) :
With seo friendly url (category__in is empty):
http://phpxpert.com/category/jquery/
Why this is happening and how can I get post_id and category_ids in my plugin?
thank you
You’ll probably find the category being used in the
category_namevariable. You can then useget_term_byto get more information about the category.