Get next and prev item from custom WP_Query and Custom Post Type

Are you maybe looking for something like this? /** * Outputs blog / archive pagination * */ function my_pagination(){ global $wp_query; $total_pages = $wp_query->max_num_pages; if ($total_pages > 1): $current_page = max(1, get_query_var(‘paged’)); echo paginate_links(array( ‘current’ => $current_page, ‘total’ => $total_pages, ‘prev_text’ => ‘Prev’, ‘next_text’ => ‘Next’, ‘type’ => ‘list’ )); endif; } Then include it … Read more

WP_Query – display posts by custom field and order by another

$q = new WP_Query( array( ‘meta_query’ => array( ‘relation’ => ‘AND’, ‘state_clause’ => array( ‘key’ => ‘state’, ‘value’ => ‘Wisconsin’, ), ‘city_clause’ => array( ‘key’ => ‘city’, ‘compare’ => ‘EXISTS’, ), ), ‘orderby’ => array( ‘city_clause’ => ‘ASC’, ‘state_clause’ => ‘DESC’, ), ) ); You can use this query for ordering, even with more than … Read more

WordPress Query – Display 5 posts (same post type), each from a given tag

Managed to get what I wanted like so: // first query $first_ids = get_posts( array( ‘post_type’ => POST_TYPE_KIB_HIREK, ‘posts_per_page’ => 1, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, // popular – ha a legolvasott ‘tag_id’ => 102, ‘order’ => ‘DESC’, ‘fields’ => ‘ids’, ‘post_status’ => ‘publish’, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ )); // second query … Read more