-
AuthorPosts
-
November 6, 2018 at 10:42 pm #1030613
I’m trying to exclude a single category from showing up in the post navs on portfolio items. I can see how to limit post nav to one category but in this case it’s just one category that I want to remove and never show up in post nav. I see that there’s a “$settings[‘excluded_terms’]” setting but putting either the portfolio category or the slug in there didn’t do anything. How do I exclude a category from this?
November 9, 2018 at 6:10 am #1031541Hey calebcuster,
Sorry for the late reply, I believe this solution will helpBest regards,
MikeNovember 9, 2018 at 11:22 pm #1031864Hi Mike,
Thanks but I couldn’t get this to work. I have it running in a child theme and I think the code has been updated some since 2013. The syntax is a little bit different. This is what I have in my functions.php in my child theme:
if(!function_exists('avia_post_nav')) { function avia_post_nav($same_category = true, $taxonomy = 'category') { global $wp_version; $settings = array(); $settings['same_category'] = $same_category; $settings['excluded_terms'] = '10'; $settings['wpversion'] = $wp_version; //dont display if a fullscreen slider is available since they overlap if((class_exists('avia_sc_layerslider') && !empty(avia_sc_layerslider::$slide_count)) || class_exists('avia_sc_slider_full') && !empty(avia_sc_slider_full::$slide_count) ) $settings['is_fullwidth'] = true; $settings['type'] = get_post_type(); $settings['taxonomy'] = ($settings['type'] == 'portfolio') ? 'portfolio_entries' : $taxonomy; if(!is_singular() || is_post_type_hierarchical($settings['type'])) $settings['is_hierarchical'] = true; if($settings['type'] === 'topic' || $settings['type'] === 'reply') $settings['is_bbpress'] = true; $settings = apply_filters('avia_post_nav_settings', $settings); if(!empty($settings['is_bbpress']) || !empty($settings['is_hierarchical']) || !empty($settings['is_fullwidth'])) return; if(version_compare($settings['wpversion'], '3.8', '>=' )) { $entries['prev'] = get_previous_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']); $entries['next'] = get_next_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']); } else { $entries['prev'] = get_previous_post($same_category, '10'); $entries['next'] = get_next_post($same_category, '10'); } $entries = apply_filters('avia_post_nav_entries', $entries, $settings); $output = ""; foreach ($entries as $key => $entry) { if(empty($entry)) continue; $tc1 = $tc2 = ""; $link = get_permalink($entry->ID); $image = get_the_post_thumbnail($entry->ID, 'square'); $class = $image ? "with-image" : "without-image"; $output .= "</a>"; } return $output; } }
November 10, 2018 at 6:50 pm #1032055Hi,
I will ask the rest of the team for any ideas, thanks for your patience.Best regards,
MikeNovember 14, 2018 at 12:35 am #1033278Hi Mike – How are things looking on this?
November 14, 2018 at 4:35 am #1033307Hi,
Thank you for your patience, I’m sure a senior member will assist with this soon. I tried to research this some more and have tried a few solutions on my localhost, without success.Best regards,
MikeDecember 10, 2018 at 8:37 pm #1043315Hi Mike, any updates on this?
December 11, 2018 at 6:37 am #1043565Hi!
You can try this filter.
add_filter('avia_post_nav_settings', 'avia_post_nav_settings_mod'); function avia_post_nav_settings_mod($settings) { if( is_singular('portfolio') ) { $settings['taxonomy'] = 'portfolio_entries'; $settings['excluded_terms'] = '10'; } return $settings; }
Don’t forget to remove the previous modification.
Best regards,
Ismael -
AuthorPosts
- You must be logged in to reply to this topic.