-
AuthorPosts
-
August 20, 2020 at 4:37 pm #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
August 20, 2020 at 5:13 pm #1239588This 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
August 20, 2020 at 6:00 pm #1239601Hi 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.Thank you.
August 20, 2020 at 6:27 pm #1239607Sorry, my bad… I should read more carefully :-)
RobAugust 26, 2020 at 12:50 pm #1240904Hi,
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,
IsmaelAugust 26, 2020 at 12:58 pm #1240905Hi 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!
August 27, 2020 at 12:15 am #1241041Hi,
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 -
AuthorPosts
- The topic ‘Next Previous Portfolio Items’ is closed to new replies.