Include tags in WP_Query
This solution may work for you also Include custom taxonomy term in search
This solution may work for you also Include custom taxonomy term in search
Adding ignore sticky line inside array should solve the issue 🙂 $args = array( ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘6’, ‘ignore_sticky_posts’ => 1,//this is the one 🙂 ‘paged’ => $paged, );
Your setup isn’t supported by WP_Query. One approach is to use the posts_where filter of WP_Query (there are other ways possible, like collecting post ID’s instead from different queries.) to adjust the SQL query. To avoid string replaces we could use for example: $custom_query_args = [ ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ]; // Add … Read more
Here’s what you can do. At the top of your page, run your first WP_Query. Calculate the number of posts you need for your secondary query by using the number of posts IN query cat_a divided by 3 and using PHP floor() to drop any remainder. This will ensure that your second query only has … Read more
$the_query->the_post() is what increments the counter and loads the next post’s data. You can also explicitly set the internal counter to an arbitrary number and begin incrementing from there… $the_query->current_post = 3; $the_query->the_post(); the_title(); // this will output the 4th post’s title
To expand on the answer by Global: Paste this into your theme’s functions.php: function get_stations_query( $terms ) { //create new query object $query = new WP_Query( array( ‘post_type’ => ‘stations’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘genres’, ‘field’ => ‘name’, ‘terms’ => $terms … Read more
There should be no reason why you should get results with query_posts and not with WP_Query. query_posts uses WP_Query, so both should work the same. Your code is really messy and you are using miltiple syntaxes which makes your code hard to debug. This leads hiding obvious bugs and really send you on unnecessary wild … Read more
As defined by the WordPress codex use this to get the parent get_post_ancestors( $post ) , The direct parent is returned as the first value in the array. Edit: get_post_ancestors( get_queried_object_id() ) can also work WordPress Codex
Edited to reflect question in OP’s comment. The contents of the tax_query array are not exactly right: as you’re querying by slug, the field parameter of the individual taxonomy query should be “slug”. You’re currently basically querying for all service posts from all service categories (well, not even that, because get_terms returns objects, but still). … Read more
I fixed my problem as follows: // Adds rewrite rules for shop post type function gtp_add_shop_rewrite_rules() { add_rewrite_rule( ‘^shop/([^/]*)/([^/]*)/([^/]*)$’, ‘index.php?shop-category=$matches[1]&width=$matches[2]&height=$matches[3]’, ‘top’ ); add_rewrite_rule( ‘^shop/([^/]*)/([^/]*)$’, ‘index.php?shop-category=$matches[1]&width=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘^shop/([^/]*)$’, ‘index.php?shop-category=$matches[1]’, ‘top’ ); } add_action(‘init’, ‘gtp_add_shop_rewrite_rules’, 10, 0);