Tagged: 

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #283424

    Hello,

    I’m using the Enfold theme portfolio post type and I have 2 different categories set up: one for “Film”, and one for “Commercial”.

    I’d like to use the avia post nav tabs to navigate between only portfolio items that have been categorized under “Film” when viewing viewing “Film” projects. I’d also like to have the same behavior for portfolio items that are categorized as “Commercial”. Unfortunately, the post nav tabs are navigating between all portfolio posts regardless of category.

    Is there any way to set this kind of behavior up, or to at least have the post nav tabs navigate through all “Film” categorized portfolio posts before navigating through portfolio posts of another category? right now it’s just going through all portfolio posts in order of oldest to newest without looking at the category.

    #283467
    #284378

    Hi Josue,

    And thanks for the direction!

    I also needed to customize some of the text in the <h4 class=’proj-nav-title’> of the post nav tabs so I ended up copying the whole
    avia_post_nav function into my child theme’s functions.php to do that customization and then set $same_category parameter to “true”:

    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'] = '';
    		$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($settings['same_category']);
    	            $entries['next'] = get_next_post($settings['same_category']);
    	        }
    	        
    		$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 class='avia-post-nav avia-post-{$key} {$class}' href='{$link}' >";
    		    $output .= "    <span class='label iconfont' ".av_icon_string($key)."></span>";
    		    $output .= "    <span class='entry-info-wrap'>";
    		    $output .= "        <span class='entry-info'>";
                $tc3    .= "        <h4 class='proj-nav-title'>View Another Project</h4>";
    		    $tc1     = "            <p class='entry-title'>".avia_backend_truncate(get_the_title($entry->ID),75," ")."</p>";
    if($image)  $tc2     = "            <span class='entry-image'>{$image}</span>";
                $output .= $key == 'prev' ?  $tc3.$tc1.$tc2 : $tc2.$tc3.$tc1;
                $output .= "        </span>";
                $output .= "    </span>";
    		    $output .= "</a>";
    		}
    		return $output;
     
            
            
    	}
    }
    #284384

    Great, if you have any additional question please let me know.

    Best regards,
    Josue

    #400514

    Hi.
    Here is my test website: http://twinmotion.abvent.com/quest-ce-que-cest/
    I would like to navigate within the same category posts. The category name is “Description”.
    I tried the way as in the post Josue mentioned before (https://kriesi.at/support/topic/avia-post-nav-with-the-same-category/), but nothing happens.

    I tried the juicesandmilks’ way and it works more or less. But it is far more complex and I don’t need to customize the buttons.
    Could you help me please ?
    Tell me if you need more infos.
    Thanks
    Riccardo

    #400771

    Hi,

    Can you please create us a WordPress administrator account? post it here as a private reply.

    Regards,
    Josue

    #401365
    This reply has been marked as private.
    #401874

    Hey!

    I’m sorry, I copied the whole avia_post_nav function to the child theme’s functions.php and it somehow broke the site because there is an excess bracket. Please override the functions.php on your child theme folder. Add this code:

    http://pastebin.com/tNSKxzJ7

    Again, I’m very sorry for the inconvenience.

    Regards,
    Ismael

    #402009

    Nice! Thanks.
    I fixed the problem.
    Your code works perfectly.

    Thanks again.
    Riccardo

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Set Avia Post Nav to only navigate between posts of the same category’ is closed to new replies.