Prev/Next links that follow a custom menu order?
Prev/Next links that follow a custom menu order?
Prev/Next links that follow a custom menu order?
next_post_link() – how to add url parameter
So I asked ChatGPT and it comes with a working solution for me: <?php $prev_post = get_previous_post(true, ”, ‘listing_category’); if (!empty($prev_post)) : ?> <a href=”<?php echo get_permalink($prev_post->ID); ?>”> <?php echo get_the_post_thumbnail($prev_post->ID, ‘thumbnail’); ?> << <?php echo esc_html($prev_post->post_title); ?> </a> <?php endif; ?> </div> <div class=”next-post-link”> <?php $next_post = get_next_post(true, ”, ‘listing_category’); if (!empty($next_post)) : ?> … Read more
The article you linked to already has a solution written by the co-founder of WordPress Mike Little: https://digwp.com/2012/05/post-navigation-author-category/#comment-36899 In the spirit of constructive criticism, the correct solution to this is in two parts: Firstly, the third parameter to previous_post_link() and next_post_link() is a flag to say keep the same category. Modify your theme (probably in … Read more
Wherever you want to place your image: <?php get_the_post_thumbnail( get_previous_post(), [ 150, 150 ] ) ; ?> <?php get_the_post_thumbnail( get_next_post(), [ 150, 150 ] ) ; ?> You can replace the sizes [ 150, 150 ] with the ‘thumbnail’. Edit: The code that works for me: $next_post = get_next_post(); $previous_post = get_previous_post(); the_post_navigation( array( ‘prev_text’ … Read more
on attachment.php, how to display previous and next attachment links that follow the same order as a custom WP Query
Yes if you just need to add a function you can put that in a new plugin. Plugins don’t have to be complicated: a single file with a header comment will do. e.g. see the Hello Dolly plugin bundled with WordPress.
I solved it by abandoning the code and registering a new taxonomy. I then used this code in single.php: <?php if (has_term(‘[TERM-NAME]’, ‘[TAXONOMY-NAME]’)) : ?> <div class = “next-post”><?php next_post_link(‘%link »’, ‘%title’, true, ”, ‘[TAXONOMY-NAME]’) ?></div> <div class = “prev-post”><?php previous_post_link(‘« %link’, ‘%title’, true, ”, ‘[TAXONOMY-NAME’) ?></div> <?php endif; ?> Doing it like this allows … Read more
It sends you to the next/prev post by date of been published. I don’t know what gives you these next/prev links and where (single.php, category.php, archive.php or any other custom template file). Without knowing more (some code example) all that I can give to you is this: $page_nr=”&paged=”; $page_nr = get_query_var( ‘paged’ ) ? $page_nr.get_query_var( … Read more
Back with WordPress 3.4.1 the function next_post_link() did not have – see source – the $taxonomy parameter, so it won’t work, no matter what. IIRC the parameter is available since WP 3.8 or 3.9 – but those are pretty old too. Just to say that very clearly, do NOT use such a old version(s) of … Read more