Tag Info

New answers tagged

0

So digging around a little i couldn't find a solution where the WP_Query wasn't used, so i just stuck with the query method, Using WP_Query this snippet will display the latest post that is published by the user that is logged in. $user_id = get_current_user_id(); $args=array( 'post_type' => 'POSTTYPE', 'post_status' => 'published', ...


0

I have a custom template and I struggled hours to show the pagination component. here what's worked for me. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'posts_per_page' => 3, 'orderby' => 'menu_order', 'order'=> 'ASC', 'paged'=>$paged, 'post_type' => 'projects' ); $projects = new ...


2

As documented in the codex you could use the following $query = new WP_Query( array( 'category__and' => array( 2, 6 ) ) ); //post has to be in category with ID 2 AND 6


-1

You can use the WP_QUERY class to search for the posts in some specific categories, here is an example: $query = new WP_Query( 'cat=2,6,17,38' ); Here is a link to the documentation where they explain how to use the results to build a loop and display the posts in the results.


0

The Codex says: Note: The category parameter needs to be the ID of the category, and not the category name. Note: The category parameter can be a comma separated list of categories, as the get_posts() function passes the 'category' parameter directly into WP_Query as 'cat'. So it'd be same as WP_Query()'s Category parameter - cat.


0

Since wordpress multisite uses different tables for all blogs, it is very inefficient to get all recent articles of all blogs (content aggregation) on display time since you have to query all blogs, sort the articles by date and display the ammount you need. Plugins like WordPress Post Indexer (https://premium.wpmudev.org/project/post-indexer) additional ...


0

This is strange and should not happen by default. get_posts uses WP_Query. If you look at the source code of get_posts, all the parameters passed to get_posts is passed unchanged to WP_Query except parameters like category which is changed to cat, the include and exclude parameters to include or exclude certain posts which is changed to post__in and ...


0

Assuming that the query works and you get all posts with ss_category terms (instead of those with ss_aff_category = true only), I think this should work: $args = array( 'post_type' => array('advertisers_cats'), 'posts_per_page' => 9, 'tax_query' => array( array( 'taxonomy' => 'ss_category', 'terms' ...



Top 50 recent answers are included