Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #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?

    #1031541

    Hey calebcuster,
    Sorry for the late reply, I believe this solution will help

    Best regards,
    Mike

    #1031864

    Hi 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;
     
            
            
    	}
    }
    
    #1032055

    Hi,
    I will ask the rest of the team for any ideas, thanks for your patience.

    Best regards,
    Mike

    #1033278

    Hi Mike – How are things looking on this?

    #1033307

    Hi,
    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,
    Mike

    #1043315

    Hi Mike, any updates on this?

    #1043565

    Hi!

    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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.