Home › Forums › Support › Exclude category or specific posts from related posts This topic has 16 replies, 3 voices, and was last updated 3 years, 7 months ago by Leo. Viewing 15 posts - 1 through 15 (of 17 total) 1 2 → Author Posts September 16, 2020 at 8:17 am #1445939 Olaniyi Hi, How can I exclude multiple posts or a category from the related posts section; <nav id=”nav-below” class=”post-navigation”> https://www.dropbox.com/s/42u60ovytfp64gm/2020-09-16%2016_15_31-Window.png?dl=0 September 16, 2020 at 8:30 am #1445960 LeoStaff Customer Support Hi there, Would something like this help? https://docs.generatepress.com/article/generate_category_post_navigation/ September 16, 2020 at 8:32 am #1445967 Olaniyi Yes, it should solve the problem. September 16, 2020 at 8:33 am #1445969 LeoStaff Customer Support Glad to hear ๐ September 16, 2020 at 9:10 am #1446024 Olaniyi Hi, Can you help with a sample code, struggling to solve it by myself. September 16, 2020 at 9:18 am #1446032 LeoStaff Customer Support Try this: add_filter( 'generate_category_post_navigation', '__return_true' ); Adding PHP: https://docs.generatepress.com/article/adding-php/ September 16, 2020 at 9:19 am #1446036 Olaniyi I got this part, the code I was asking for: If I want this to work for a specific category rather than the whole website. September 16, 2020 at 9:29 am #1446044 LeoStaff Customer Support Try this: add_action( 'wp', 'lh_category_navigation' ); function lh_category_navigation() { if ( is_category( 'CATEGORY NAME' ) ) { add_filter( 'generate_category_post_navigation', '__return_true' ); } } https://codex.wordpress.org/Conditional_Tags#A_Category_Page September 16, 2020 at 9:34 am #1446055 Olaniyi This works, Thanks! September 16, 2020 at 9:35 am #1446063 LeoStaff Customer Support No problem ๐ September 18, 2020 at 1:25 pm #1449213 Olaniyi Hello, Is it possible to prevent some specific posts from showing in the post navigation? For example, if I have some posts unsuitable for kids, and I don’t want them to show under any post navigation, how would I exclude these posts? September 18, 2020 at 1:38 pm #1449229 ElvinStaff Customer Support Hi, Consider creating an R-18 category for posts that are not suitable for kids/minors. You can then exclude that R-18 category the same way you’ve excluded the other categories. September 18, 2020 at 2:03 pm #1449257 Olaniyi Yeah, that would work but it is not ideal in the current situation, which is why I reopened the topic. Is there any post specific situation, maybe excluding with post ID, something like that? September 18, 2020 at 2:09 pm #1449264 LeoStaff Customer Support It’s pretty complicated to modify the WordPress posts loop like that. A plugin like WP Show Posts should help: https://en-ca.wordpress.org/plugins/wp-show-posts/ Then you can use the exclusion option: https://docs.wpshowposts.com/article/more-settings-overview/#exclude-post-ids September 18, 2020 at 2:17 pm #1449276 Olaniyi Alright, I will keep at it, thanks. Author Posts Viewing 15 posts - 1 through 15 (of 17 total) 1 2 → You must be logged in to reply to this topic. Log In Username: Password: Keep me signed in Log In