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

Plugin: Events manager – Next and previous event

The function WordPress ultimately uses for this is get_adjacent_post(), which has filters that allow you to modify the query directly. You’d have to modify the JOIN, WHERE and ORDER BY clauses to join the post meta table and order by your custom field. Another option is the Ambrosite Next/Previous Post Link Plus plugin.

Show multiple next and previous posts

This one is not a good way to do it but it’s easy to implement global $post; $original = $post; $next = get_next_post(true); $prev = get_previous_post(true); $post = $next; next_post_link(); $post = $original; next_post_link(); // display current post previous_post_link(); $post = $prev; previous_post_link(); $post = $original; To make the code more efficient, you can copy … Read more

How can I change the prev / next buttons text to Dutch?

If you’re simply using one language on your site: Find the utility.php file in your themes folder with location lib/functions/utility.php Next find the lines 227 and 231 and change the __( ‘Previous Post’, ‘contango’ ) and __( ‘Next Post’, ‘contango’ ) to your desired values. For example: previous_post_link( ‘%link’, __( ‘vorige post’, ‘contango’ ) . … Read more

Get previous/next post from (specific) category

When in_same_term parameter in get_next_post() / get_previous_post() function is set to TRUE, a post is selected from any category assigned to the current post. As you wrote, you can not use the exclude parameter in this case. Using the get_{$adjacent}_post_where filter, you can skip product in the category list, which you are looking for posts. … Read more

Theme Option not Working Inside a Function

1) Move the function to the functions.php file, that’s where it belongs. Put it at the end before any closing ?>: function my_theme_navigation() { global $shortname; if( get_option( $shortname . ‘_next_prev_or_paginate’ ) == ‘Next’ ) : // the block for next-prev navigation previous_posts_link (‘Newer’); next_posts_link(‘Older’); else : // the block for pagination global $wp_query; $big … Read more

next and previous year month and day for archive page

thank u all i just did a simple code to get what i want <?php $prevyear = date(‘2150’) – 0001; $nextyear = date(‘2150′) + 0001; $prevmonth = date(’01’) – 01; $nextmonth = date(’01’) + 01; echo echo get_year_link($prevyear).”<br />”.get_year_link($nextyear).”<br />”.get_year_link($prevmonth).”<br />”.get_year_link($nextmonth).”<br />”; ?>