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

    Hi everyone,
    I have a custom function for the next and previous buttons that allows me to browse only with the same category on a specific page. This function is added to pages with a code block.
    I would like to be able to use this function only for the portfolio, but it is not working.
    I know that this is not related to Enfold, but if there is anyone who can help me, I will appreciate it.

    // Função prev-next dos portfolios
    add_shortcode( ‘prev’, ‘prev_shortcode’ );
    add_shortcode( ‘next’, ‘next_shortcode’ );
    function prev_shortcode() {
    global $post;
    $result = get_previous_post_link( ‘<div class=”nav-previous”>%link</div>’, __(‘<span class=”av-icon-char” style=”” aria-hidden=”true” data-av_icon=”” data-av_iconfont=”entypo-fontello” data-avia-icon-tooltip=”Anterior”></span>’, ‘prev-next’ ), true );
    return $result;
    }
    function next_shortcode() {
    global $post;
    $result = get_next_post_link( ‘<div class=”nav-next”>%link</div>’, __(‘<span class=”av-icon-char” style=”” aria-hidden=”true” data-av_icon=”” data-av_iconfont=”entypo-fontello” data-avia-icon-tooltip=”Seguinte”></span>’, ‘prev-next’ ), true );
    return $result;
    }

    Best regards

    #1239588

    This works for me in the child theme functions.php to keep the previous-next butons only in one specific portfolio category.
    Maybe it works for you too.

    // make previous-next buttons stay within the relevant portfolio category (multiple portfolios)
    add_filter( 'avia_post_nav_entries', 'enfold_customization_postnav', 10, 2);
    function enfold_customization_postnav($entries, $settings)
    {
    	if($settings['type'] == 'portfolio')
    	{
    		$settings['same_category'] = true;
    		$entries['prev'] = get_next_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    		$entries['next'] = get_previous_post($settings['same_category'], $settings['excluded_terms'], $settings['taxonomy']);
    	}
        return $entries;
    }

    Rob

    #1239601

    Hi Rob,
    Thank you very much for your help, but i do not use the the (avia_post_nav_entries).
    As i tried to explain, i use a custom function navigation that was inserted by a shortcode with a code block.

    Next Prev

    Thank you.

    #1239607

    Sorry, my bad… I should read more carefully :-)
    Rob

    #1240904

    Hi,

    Thank you for the inquiry.

    The 5th parameter of the get_$adjacent_post_link() is the $taxonomy which is set to “category” by default. You have to replace it with “portfolio_entries” if you want the links to work on portfolio items.

    // https://developer.wordpress.org/reference/functions/get_previous_post_link/

    Best regards,
    Ismael

    #1240905

    Hi Ismael,
    Thank you very much for your help, however I had already managed to solve the problem and it was exactly as you indicated and i would like to share it:

    // Função prev-next dos portfolios
    add_shortcode( ‘prev’, ‘prev_shortcode’ );
    add_shortcode( ‘next’, ‘next_shortcode’ );
    function prev_shortcode() {
    global $post;
    $result = get_previous_post_link(
    $format = ‘<div class=”nav-previous”>%link</div>’,
    $link = ‘<span class=”av-icon-char” style=”” aria-hidden=”true” data-av_icon=”” data-av_iconfont=”entypo-fontello” data-avia-icon-tooltip=”%title”></span>’,
    $in_same_term = true,
    $excluded_terms = ”,
    $taxonomy = ‘portfolio_entries’);
    return $result;
    }
    function next_shortcode() {
    global $post;
    $result = get_next_post_link(
    $format = ‘<div class=”nav-next”>%link</div>’,
    $link = ‘<span class=”av-icon-char” style=”” aria-hidden=”true” data-av_icon=”” data-av_iconfont=”entypo-fontello” data-avia-icon-tooltip=”%title”></span>’,
    $in_same_term = true,
    $excluded_terms = ”,
    $taxonomy = ‘portfolio_entries’);
    return $result;
    }

    Best regards!

    #1241041

    Hi,

    I’m glad this was resolved and thanks for sharing the solution. If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Next Previous Portfolio Items’ is closed to new replies.