-
AuthorPosts
-
November 26, 2015 at 10:53 pm #543432
Hi!
Im building a catalogue with woocommerce,
when u are in the single product page If you hover your mouse pointer to the left or right of the screen there is an animated prev/next post arrow.
They point to previous or next posts, in that case product. How can i limit that navigation to a single category?
I already tried with this code but nothing happens:add_filter(‘avia_post_nav_categories’, ‘use_same_category_filter’);
function use_same_category_filter($same_category)
{
$same_category = true;
return $same_category;
}Could you help me to solve my problem?
Thank u in advance!
FilippoNovember 27, 2015 at 6:53 pm #543780Hey frenchfries!
Add that code to a child theme and then send us a WordPress login so we can check.
Regards,
ElliottNovember 28, 2015 at 6:31 pm #543971November 28, 2015 at 8:20 pm #543996Hey!
I am sorry, but I do not see anywhere your web site URL.
how can we login?Regards,
BasilisNovember 28, 2015 at 8:40 pm #543999November 30, 2015 at 9:25 pm #544803Hi! i really need your help guys!!!
thank you! :)December 2, 2015 at 7:16 pm #546057Hey!
Hmm, I did some testing on my XAMPP setup and I could only get it to work with this for some reason.
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['prev'] = get_previous_post(true, $settings['excluded_terms'], 'product_cat'); $entries['next'] = get_next_post(true, $settings['excluded_terms'], 'product_cat'); } 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; $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; } }
You can paste that into the child theme functions.php file.
Cheers!
ElliottDecember 3, 2015 at 11:02 am #546328I love you!!! It’s working!!! big thankyou!!!!!!!!!!!!
-
AuthorPosts
- The topic ‘Limit navigation between posts to one category of woocommerce product’ is closed to new replies.