Not working in widget
-
Hey,
Great plugin! I am trying to get it working with one of my widgets. This widget displays in the footer of my website, and displays posts from a single specific category. I am trying to get this to work to display the custom order within the widget (new WP_Query object), regardless of what page is currently being shown, as this widget could appear any where on the website. I’ve already tried your suggestion to Dan from an older post, but it does not seem to be working.
Here is the loop I am trying to integrate it with:
// Set featured post query arguments $args = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 1, 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $category, ), ), ); // Set thumbnail post query arguments $args2 = array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 4, 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $category, ), ), 'offset' => 1, ); add_filter('pre_get_posts', array($this, 'custom_pre_get_posts')); // Query the latest post $firstNewsPost = null; $firstNewsPost = new WP_Query( $args ); // Query the remaining posts $thumbnailNewsPost = null; $thumbnailNewsPost = new WP_Query( $args2 ); remove_filter('pre_get_posts', array($this, 'custom_pre_get_posts'));
Any help would be greatly appreciated.
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Not working in widget’ is closed to new replies.