Problem: WP_Query always show all posts instead of from just one category
-
I’ve got a problem with WP_Query and I was wondering if someone could help.
I’m registering a widget in the functions.php file of my theme, but the WP_Query command keeps returning all posts, while I am specifying a category. This is the code:
add_action('init','initTVwidget'); function initTVwidget() { if ( function_exists('register_sidebar_widget') ) register_sidebar_widget(__('TV and player'), 'widget_tvAndCartoonPlayer'); } function widget_tvAndCartoonPlayer() { $blog_posts = new WP_Query('showposts=2&cat=25'); print_r($blog_posts); }
Is there a scope problem? Because when I place the same WP_Query code snippet outside of the function in the functions.php it works.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Problem: WP_Query always show all posts instead of from just one category’ is closed to new replies.