Wp_query Add specific pending posts

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

Moving the array pointer inside a WP_Query while loop

$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

Clean up WordPress code that repeats

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

unable to retrive parent page information

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

WordPress add_rewrite_rule() cannot visit lower url levels

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);