Tagged: x
-
AuthorPosts
-
June 28, 2016 at 6:28 am #1063030
ArtOfSpringParticipantHi there,
I’m using an Integrity child theme for a WooCommerce online shop.
I activated breadcrumbs to enable the navigation arrows on a product page.
Also I set up product categories (Sake, Whisky, Accessoires).But using the arrows to navigate between the different products it seems to be a random order(?).
This is a “Whisky”: http://stage3.art-of-spring.marketing/produkt/houga/
After navigating to the right a “Sake” shows up: http://stage3.art-of-spring.marketing/produkt/ginshu-ginjo/
Then one more Sake and the next in line is an “Accessoire”.Can I customize the order? I want to achieve that a product of one category e.g. “Sake” won’t be followed by a product of another category. Any idea?
Thank you
June 28, 2016 at 7:56 am #1063139
Paul RModeratorHi,
To restrict the navigation to the same category, you can add this in your child theme’s functions.php file.
function x_entry_navigation() { $stack = x_get_stack(); if ( $stack == 'ethos' ) { $left_icon = '<i class="x-icon-chevron-left" data-x-icon=""></i>'; $right_icon = '<i class="x-icon-chevron-right" data-x-icon=""></i>'; } else { $left_icon = '<i class="x-icon-arrow-left" data-x-icon=""></i>'; $right_icon = '<i class="x-icon-arrow-right" data-x-icon=""></i>'; } $is_ltr = ! is_rtl(); $prev_post = get_adjacent_post( true, '', false ); $next_post = get_adjacent_post( true, '', true ); $prev_icon = ( $is_ltr ) ? $left_icon : $right_icon; $next_icon = ( $is_ltr ) ? $right_icon : $left_icon; ?> <div class="x-nav-articles"> <?php if ( $prev_post ) : ?> <a href="<?php echo get_permalink( $prev_post ); ?>" title="<?php __( 'Previous Post', '__x__' ); ?>" class="prev"> <?php echo $prev_icon; ?> </a> <?php endif; ?> <?php if ( $next_post ) : ?> <a href="<?php echo get_permalink( $next_post ); ?>" title="<?php __( 'Next Post', '__x__' ); ?>" class="next"> <?php echo $next_icon; ?> </a> <?php endif; ?> </div> <?php }The items are ordered from latest to oldest so you can modify the date to order it.
Hope that helps.
June 28, 2016 at 8:57 am #1063215
ArtOfSpringParticipantHi there,
I added the code to my child theme’s function.php file but now the arrows disappeared.
June 28, 2016 at 9:00 am #1063219
Paul RModeratorHi,
Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:
– Link to your site
– WordPress Admin username / password
– FTP credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
June 28, 2016 at 10:18 am #1063373
ArtOfSpringParticipantThis reply has been marked as private.June 28, 2016 at 10:16 pm #1064261
LelyModeratorThis reply has been marked as private.June 29, 2016 at 3:31 am #1064477
ArtOfSpringParticipantThis reply has been marked as private.June 29, 2016 at 6:30 am #1064657
Paul RModeratorHi,
I tried to login to ftp but there are several directories.
May I know which directory your site points to.
Thanks
June 29, 2016 at 7:15 am #1064701
LelyModeratorHi There,
As you are targeting products, get_adjacent_posts() also require a taxonomy slug, i.e., product_cat for product post type. Please update above code to this:
function x_entry_navigation() { $stack = x_get_stack(); if ( $stack == 'ethos' ) { $left_icon = '<i class="x-icon-chevron-left" data-x-icon=""></i>'; $right_icon = '<i class="x-icon-chevron-right" data-x-icon=""></i>'; } else { $left_icon = '<i class="x-icon-arrow-left" data-x-icon=""></i>'; $right_icon = '<i class="x-icon-arrow-right" data-x-icon=""></i>'; } if ( x_is_product() ) { $taxonomy = 'product_cat'; } else { $taxonomy = 'category'; } $is_ltr = ! is_rtl(); $prev_post = get_adjacent_post( true, '', false,$taxonomy ); $next_post = get_adjacent_post( true, '', true,$taxonomy ); $prev_icon = ( $is_ltr ) ? $left_icon : $right_icon; $next_icon = ( $is_ltr ) ? $right_icon : $left_icon; ?> <div class="x-nav-articles"> <?php if ( $prev_post ) : ?> <a href="<?php echo get_permalink( $prev_post ); ?>" title="<?php __( 'Previous Post', '__x__' ); ?>" class="prev"> <?php echo $prev_icon; ?> </a> <?php endif; ?> <?php if ( $next_post ) : ?> <a href="<?php echo get_permalink( $next_post ); ?>" title="<?php __( 'Next Post', '__x__' ); ?>" class="next"> <?php echo $next_icon; ?> </a> <?php endif; ?> </div> <?php }Hope this helps.
June 29, 2016 at 8:04 am #1064793
ArtOfSpringParticipantThis reply has been marked as private.June 29, 2016 at 8:05 am #1064794
ArtOfSpringParticipantHi Lely,
the updated code seems to work!
Thank you
June 29, 2016 at 8:56 am #1064896
Paul RModeratorGlad to know. Have a great day!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1063030 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
