-
AuthorPosts
-
November 7, 2025 at 2:56 pm #1491033
Hi there,
When using the next and previous buttons in a standard post, I’d like the next or previous post to be from the same category.
I found this filter (in a topic from 2017 …) but that doesn’t work for me:add_filter(‘avia_post_nav_categories’, ‘use_same_category_filter’);
function use_same_category_filter($same_category)
{
$same_category = true;
return $same_category;
}Is there another solution maybe?
Beste regards,
Steven
November 8, 2025 at 4:12 pm #1491062try first this shorter form – maybe that will work for you.
(do not know if the old filter is still ther avia_ …)
there are more complex snippets – but in almost all installations this will work:function enfold_customization_postnav($settings){ $settings['skip_output'] = false; $settings['same_category'] = true; return $settings; } add_filter('avf_post_nav_settings','enfold_customization_postnav', 10, 1);edit: here is one with more options:
function my_avf_post_nav_settings( array $settings ){ if( true === $settings['is_hierarchical'] ){ $settings['skip_output'] = true; return $settings; } if( ! in_array( $settings['type'], array( 'post', 'portfolio' ) ) ){ $settings['skip_output'] = true; return $settings; } $settings['same_category'] = true; $settings['is_fullwidth'] = false; $settings['skip_output'] = false; return $settings; } add_filter( 'avf_post_nav_settings', 'my_avf_post_nav_settings', 10, 1 );November 10, 2025 at 11:20 am #1491106Hi Günter,
Thank you for your time and effort. Unfortunately, both options don’t work. The only result is that the next/previous buttons disappear.
Best regards,
Steven
November 10, 2025 at 11:35 am #1491107with this snippet you do not even need to set the enfold options on post-navigation.
You can set with that filter even to loop:function my_avf_post_nav_settings( array $settings ){ if( true === $settings['is_hierarchical'] ){ $settings['skip_output'] = true; return $settings; } // the post-types inside the array are allowed to have post-navigation if( ! in_array( $settings['type'], array( 'post', 'portfolio' ) ) ){ $settings['skip_output'] = true; return $settings; } $settings['loop_post_nav'] = true; $settings['same_category'] = true; $settings['is_fullwidth'] = false; $settings['skip_output'] = false; return $settings; } add_filter( 'avf_post_nav_settings', 'my_avf_post_nav_settings', 10, 1 );btw. if you set this (is_hierarchical) condition to false – then even pages will have post-navigation
November 10, 2025 at 12:34 pm #1491112May I see the page in question?
you are not talking about a custom post type?
if so include this (f.e.: event or tribe_events ) post-type to the arrayNovember 10, 2025 at 1:51 pm #1491116Sure: https://kunst-en-verhalen.rhijnhof.nl/test/
As you can see the previous button now links to the current page.
I did the settings in the blog layout as you suggested and to my knowledge these are normal posts …November 10, 2025 at 5:30 pm #1491129and you have another post inside category: oorlogsslachtoffers ?
i guess not:https://kunst-en-verhalen.rhijnhof.nl/category/oorlogsslachtoffers
what makes me wonder is that if there is only one post inside that category – there should be no post-nav at all.
you see – here it is working with same category:
https://kunst-en-verhalen.rhijnhof.nl/pieta/November 10, 2025 at 5:37 pm #1491130November 11, 2025 at 3:37 am #1491150Hi,
Thank you for the inquiry.
Please provide the login details in the private field so we can check this properly. Did you select the Loop post navigation option in Enfold > Blog Layout > Single Post Navigation settings? Looping will not work correctly when same_category is enabled. Try to set the Single Post Navigation to the first option (Enable post navigation).
Best regards,
IsmaelNovember 11, 2025 at 10:02 am #1491164you can see that if there are more than 1 post inside a category – it works:
https://kunst-en-verhalen.rhijnhof.nl/pieta/what makes me wonder is that on your posts with category: oorlogsslachtoffers (only 1) – there should be no post-navigation. ( Do you have in the page title that p-tag ?)
so maybe Ismael could help you with this inside your installationPS : the setting on Enfold > Blog Layout > Single Post Navigation setting is not important if you use the filter from : above
With the help of this filter, you can even handle post-types differently.
November 11, 2025 at 10:15 am #1491165By the way: What causes some inconsistencies is not the loop – that works – but when a post/portfolio has multiple categories.
For example, for a post that has category A, this leads to the next post with category A (but now this has also categories B and C, for example). This is where the decision tree opens up – if no more posts with A are found, then B or C will probably be opened.you can see it here: https://webers-testseite.de/defined-order/
This post only has one category: telemedizin – left and right post-navigation leads to only one post with that category.
But if you open the next one – this now has more than one category – so this post opens different posts etc.The same category post-navigation only makes sense if the posts are always assigned to only one category.
November 11, 2025 at 10:27 am #1491166Hi,
You’re absolutely right. Stupid of me to miss the fact that there have to be multiple posts in the same category. Otherwise, it wouldn’t work…. Well, now it does.
Regarding the <p> tag: The designer would like to have a year and a short text next to and below the title. That’s why I added the title to the post like so:
Henri Flu <span class=”jaartal”>1912-1944</span><br><p class=”ondertitel”>Geliefd huisarts en oorlogsslachtoffer</p>
But I agree it doesn’t look right when hovering over the next/previous buttons.Best regards,
Steven
November 11, 2025 at 12:39 pm #1491187a p-tag inside a span-tag ? try another span with a custom class.
i tested 2 spans – that will lead to different troubles – because the span.entry-image will be placed inside and not besides entry-title
you can use :
Henri Flu • <i>1912-1944</i><span class="ondertitel">Geliefd huisarts en oorlogsslachtoffer</span>
or
Henri Flu <i><br>1912-1944</i><span class="ondertitel">Geliefd huisarts en oorlogsslachtoffer</span>then you can colorise the i by:
#top .avia-post-nav .entry-title > i { color: #ff0; } #top .avia-post-nav .entry-image img { width: 100%; height: 100%; }
November 11, 2025 at 1:29 pm #1491190Hi,
Thanks again. I think my solution would be to hide the title tag altogether (Link naar: …) of the buttons.
title="Link naar: Henri Flu <i>1912-1944</i><br><span class="ondertitel">Geliefd huisarts en oorlogsslachtoffer</span>" aria-label="Henri Flu <i>1912-1944</i><br><span class="ondertitel">Geliefd huisarts en oorlogsslachtoffer</span>">November 11, 2025 at 4:43 pm #1491195the link comes from enfold itself. You do not need to insert on title input field links.
November 11, 2025 at 5:08 pm #1491203Sorry, that I don’t understand. Where do I find this input field?
November 11, 2025 at 11:44 pm #1491208sorry that “Link to: ” comes from Enfold – i thought that you had inserted it to the post title
November 12, 2025 at 8:31 am #1491226Morning!
Please see screenshot of what I did: https://imgur.com/I1fQbKV.
I assume there’s no way to disable the hover action?EDIT: I think I found some kind solution. Instead of adding extra text to the title, I use the manual excerpt field in the single post page. Then let Content Views pick up the excerpt instead of (part) of the content et voila!
Regards,
Steven-
This reply was modified 2 weeks, 2 days ago by
steviger.
November 12, 2025 at 9:14 am #1491228you are talking about this extra tooltip?

remove the title tag from the anchor by:
function remove_postnav_title_tags(){ ?> <script type="text/javascript"> (function($) { $(window).on('load', function(){ $('a.avia-post-nav').removeAttr('title'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'remove_postnav_title_tags');November 12, 2025 at 9:30 am #1491229That’s exactly what I meant. However as I mentioned earlier, I found another solution. May also be easier for the end user later on.
Anyway, thanks again for your time and effort.Best regards,
Steven
November 13, 2025 at 4:41 am #1491268 -
This reply was modified 2 weeks, 2 days ago by
-
AuthorPosts
- The topic ‘Next/Previous Post within same Category’ is closed to new replies.

