How to make the ethos post arrows only go the next post in a category?

Hey. I’m using ethos with articles that are in different categories by different authors. How do I make the ethos post arrows only go to the next post in a particular category?

Hi Peter,

Thanks for reaching out.

The arrow navigation uses this https://codex.wordpress.org/Function_Reference/get_adjacent_post and this is the function used for that

  function x_entry_navigation() {

  $stack = x_get_stack();

  if ( $stack == 'ethos' ) {
    $left_icon  = '<i class="x-icon-chevron-left" data-x-icon-s="&#xf053;"></i>';
    $right_icon = '<i class="x-icon-chevron-right" data-x-icon-s="&#xf054;"></i>';
  } else {
    $left_icon  = '<i class="x-icon-arrow-left" data-x-icon-s="&#xf060;"></i>';
    $right_icon = '<i class="x-icon-arrow-right" data-x-icon-s="&#xf061;"></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 article says

$taxonomy
(string) (optional) Taxonomy name, if $in_same_term is true.
Default: ‘category’

It’s already default to category and I checked and confirmed it, would you mind clarifying what you wish to achieve?

Thanks!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.