Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #193351

    Hi there!
    I have a problem regarding the portfolio items. After the grid, when I open an item, there are the buttons on the left and right side for the next item, but it seems they are the wrong way.
    If I open the very first item on the top left, then the button to the next item should be shown right not left. How can I change this?
    Thank you very much for your answer, best regards,
    dulei

    #193395

    Hi dulei07!

    It should be in the correct order but if you want to reverse it, you can edit functions-enfold.php then find this code on line 341:

     $entries['prev'] = get_previous_post($same_category);
            $entries['next'] = get_next_post($same_category);

    Replace it with:

    $entries['prev'] = get_next_post($same_category);
            $entries['next'] = get_previous_post($same_category);

    Best regards,
    Ismael

    #1113676

    Just found this old thread. I’ve watched people use my site and these buttons would behave more intuitively if functionality was reversed.
    Is this solution still valid?
    If so, I’d like to test this with a child theme. Would I have to copy the entire “functions-enfold.php” file to the child folder and then replace the code or just place the code you provided in an empty file with matching file name?

    #1114072

    Hi bluesbrush,

    Please have a look at the solution posted here
    https://kriesi.at/support/topic/nextprevious-post-arrow-same-category-content-only/#post-818822

    Best regards,
    Victoria

    #1114107

    It seems that post is all about navigating between categories. That’s cool but not what I’m trying to do. Maybe you posted the wrong topic?

    #1114121

    I figured it out. Hopefully this will help someone. I had to piece together a few threads to figure this out. The code that needs to be changed is in “functions-enfold.php” but I didn’t want my changes to be overwritten by a theme update so I copied the entire “avia_post_nav” section from “functions-enfold.php” into the “functions.php” file of my child theme because apparently “functions-enfold.php” file is not recognized in child themes and I learned you can copy functions from functions-enfold.php into the the function.php file, which is recognized by the child theme.

    So, I copied this entire section from functions-enfold.php into child theme functions.php:

    if(!function_exists('avia_post_nav'))
    {
    	function avia_post_nav($same_category = false, $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['next'] = get_previous_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    	            $entries['prev'] = get_next_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    	        }
    	        else
    	        {
    	            $entries['next'] = get_previous_post($settings['same_category']);
    	            $entries['prev'] = 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;
    			$the_title 	= isset($entry->av_custom_title) ? $entry->av_custom_title : avia_backend_truncate(get_the_title($entry->ID),75," ");
    			$link 		= isset($entry->av_custom_link)  ? $entry->av_custom_link  : get_permalink($entry->ID);
    			$image 		= isset($entry->av_custom_image) ? $entry->av_custom_image : get_the_post_thumbnail($entry->ID, 'thumbnail');
    			
                $tc1   = $tc2 = "";
                $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'>";
    		    $tc1     = "            <span class='entry-title'>{$the_title}</span>";
    if($image)  $tc2     = "            <span class='entry-image'>{$image}</span>";
                $output .= $key == 'prev' ?  $tc1.$tc2 : $tc2.$tc1;
                $output .= "        </span>";
                $output .= "    </span>";
    		    $output .= "</a>";
    		}
    		return $output;
    	}
    }
    

    and then, replaced this:

    {
    	            $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']);
    	        }

    with this:

    {
    	            $entries['next'] = get_previous_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    	            $entries['prev'] = get_next_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    	        }
    	        else
    	        {
    	            $entries['next'] = get_previous_post($settings['same_category']);
    	            $entries['prev'] = get_next_post($settings['same_category']);
    	        }

    Now, when I sort my portfolio chronologically by date, I have my newest stuff at the top and when someone opens one and clicks on the right navigation arrow, they can navigate through the portfolio in the order they appear on the page. Intuitively, most people want to click the right arrow to navigate what they perceive to be forward, through the portfolio.

    If you care to, you can preview it in action on my site here:

    #1114329

    Hi bluesbrush,

    Glad you got it working for you and thank you for sharing! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘how to reverse "next portfolio item" from left to right’ is closed to new replies.