prev/next post links with custom query
If you are using a custom query you will have to build your own navigation.
If you are using a custom query you will have to build your own navigation.
I think this is a better and cleaner approach of what you are trying to achive. // get_adjacent_post will return $post object $prev_post = get_adjacent_post(true,”,true); //Using get_the_post_thumbnail() to get featured image of previous post $prev_thumbnail = get_the_post_thumbnail( $prev_post->ID, array( 100, 100)); $next_post = get_adjacent_post(true,”,false); //Using get_the_post_thumbnail() to get featured image of next post $next_thumbnail = … Read more
$excluded_terms should be the 2nd arg to get_previous_post etc, not the first. Also those filters should not be required.
How to get next post link of child custom post type from parent post and get next post link of parent post from the last child post?
I managed to modify an existing answer from a closely related thread to achieve this. You can find the answer from the related thread here. https://wordpress.stackexchange.com/a/365334/185141 add_action(‘woocommerce_before_single_product’, ‘elron_prev_next_product’); // and if you also want them at the bottom… add_action(‘woocommerce_after_single_product’, ‘elron_prev_next_product’); function elron_prev_next_product() { global $post; echo ‘<div class=”prev-next-buttons”>’; $terms = get_the_terms( $product->id, ‘product_cat’ ); foreach … Read more
Include “Scheduled” (“Future”) Posts in WordPress Post Navigation ( previous_post_link, next_post_link ) for a Specific Custom Post Type
You need to do a little “hack” to get pagination to work for your custom loop. After you define $loop, do the following: <?php // globalize $wp_query global $wp_query; // copy $wp_query into a temporary variable $temp_wp_query = $wp_query; // nullify $wp_query $wp_query = null; // move $loop into $wp_query $wp_query = $loop; ?> At … Read more
&reel=commercials?paged=2 That’s the problem at the end of that query string. You can’t start a query string twice so that ?paged=2 bit is being read as part of the reel parameter’s value. The question mark should be another & eg: ?author=2&reel=commercials&paged=2
First thing to do is check for any plugins that affect search results. The reason is that I had the ‘Search Everything’ plugin running. While it was meant to search for more results and highlight the search terms, it will change any instance of new WP_Query(); making it useless. This is the callback function to … Read more
use get_adjacent_post(). if nothing is returned for next/prev, get the first/last. Edit- just noticed your custom post type, you’ll also have to filter get_previous_post_where and get_next_post_where to pick up your cpt.