Read More Link is duplicated on category and archive pages

Our read more link “Keep Reading” is showing up twice for each post on the category pages and the archive pages. This is not happening on the home page.

Visible here:

http://andthenwetried.com/category/food/
http://andthenwetried.com/2017/06/

The homepage is working as expected here:

How can we fix this?

This is an automated message to notify you that your thread was posted in the wrong forum, and it has been moved to the correct place. A member of our team will be happy to reply just as soon as your thread is up. How support works.

For support, please post all questions in the Support Forum.

For peer to peer conversations with other Themeco customers about tips, customizations, or suggestions you are welcome to use the Conversation Forum (no official support provided here).

Design & Development, Marketing & Media, and Hosting & Optimization are for discussion with fellow Apex members about non Themeco related topics. Please keep this in mind in the future.

Thank-you!

Hello There,

Thanks for writing in! This issue may have occurred because you have a custom function overriding the read more button. Could you please post in your next reply the contents of your child theme’s functions.php file?

By the way, I noticed that you are using an older version of X. Please update to the latest version. X 5.1.1 is now available. you should be able to update it by going in your WP dashboard, Dashboard > Updates.

Please let us know how it goes.

<?php

// =============================================================================
// FUNCTIONS.PHP
// -----------------------------------------------------------------------------
// Overwrite or add your own custom functions to X in this file.
// =============================================================================

// =============================================================================
// TABLE OF CONTENTS
// -----------------------------------------------------------------------------
//   01. Enqueue Parent Stylesheet
//   02. Additional Functions
// =============================================================================

// Enqueue Parent Stylesheet
// =============================================================================

add_filter( 'x_enqueue_parent_stylesheet', '__return_true' );



// Additional Functions
// =============================================================================

add_action('x_after_view_global__content', 'add_post_tags');

function add_post_tags() {
if( is_singular('post') ) {
 if ( has_tag() ) : ?>
  <footer class="entry-footer cf">
    <?php echo get_the_tag_list( '<p><i class="x-icon-tags"></i> Tags: ', ', ', '</p>' ); ?>
  </footer>
<?php endif;
}
}



// Excerpt More String
// =============================================================================

if ( ! function_exists( 'x_excerpt_string' ) ) :
  function x_excerpt_string( $more ) {
    
    $stack = x_get_stack();

    if ( $stack == 'integrity' ) {
      return ' ... <div><a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading', '__x__' ) . '</a></div>';
    } else if ( $stack == 'renew' ) {
      return ' ... <a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading', '__x__' ) . '</a>';
    } else if ( $stack == 'icon' ) {
      return ' ...';
    } else if ( $stack == 'ethos' ) {
      return ' ...';
    }

  }
  add_filter( 'excerpt_more', 'x_excerpt_string' );
endif;

// Content More String
// =============================================================================

if ( ! function_exists( 'x_content_string' ) ) :
  function x_content_string( $more ) {
    
    $stack = x_get_stack();

    if ( $stack == 'integrity' ) {
      return '<a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading', '__x__' ) . '</a>';
    } else if ( $stack == 'renew' ) {
      return '<a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading', '__x__' ) . '</a>';
    } else if ( $stack == 'icon' ) {
      return '<a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading', '__x__' ) . '</a>';
    } else if ( $stack == 'ethos' ) {
      return '<a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading ', '__x__' ) . '<i class="x-icon x-icon-arrow-circle-right" data-x-icon="" aria-hidden="true"></i></a>';
    }

  }
  add_filter( 'the_content_more_link', 'x_content_string' );
endif;

// Read More Category
// =============================================================================

function excerpt_read_more_link($output) {
if ( !is_home() ) {
 global $post;
 return $output . '<a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading ', '__x__' ) . '<i class="x-icon x-icon-arrow-circle-right" data-x-icon="" aria-hidden="true"></i></a>';
}
}
add_filter('the_excerpt', 'excerpt_read_more_link');


// Add author box to all posts
// =============================================================================

function add_author_shortcode_to_end_of_all_posts() {

  if ( is_singular( 'post' ) ) {
    echo do_shortcode( '[gap size="3em"][author class="man" title="About The Author"]' );
  }

}

add_action( 'x_before_the_content_end', 'add_author_shortcode_to_end_of_all_posts' );




// Custom Post Author shortcode
// =============================================================================

function x_shortcode_author_v2( $atts ) {
  extract( shortcode_atts( array(
    'id'        => '',
    'class'     => '',
    'style'     => '',
    'title'     => '',
    'author_id' => ''
  ), $atts, 'x_author' ) );

  $id        = ( $id        != '' ) ? 'id="' . esc_attr( $id ) . '"' : '';
  $class     = ( $class     != '' ) ? 'x-author-box cf ' . esc_attr( $class ) : 'x-author-box cf';
  $style     = ( $style     != '' ) ? 'style="' . $style . '"' : '';
  $title     = ( $title     != '' ) ? $title : __( 'About the Author', '__x__' );
  $author_id = ( $author_id != '' ) ? $author_id : get_the_author_meta( 'ID' );

  $description  = get_the_author_meta( 'description', $author_id );
  $display_name = get_the_author_meta( 'display_name', $author_id );
  $facebook     = get_the_author_meta( 'facebook', $author_id );
  $twitter      = get_the_author_meta( 'twitter', $author_id );
  $googleplus   = get_the_author_meta( 'googleplus', $author_id );
  $instagram    = get_the_author_meta( 'instagram', $author_id );
  $author_url   = get_author_posts_url( $author_id );

  $facebook_output   = ( $facebook )   ? "<a href=\"{$facebook}\" class=\"x-author-social\" title=\"Visit the Facebook Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i> Facebook</a>" : '';
  $twitter_output    = ( $twitter )    ? "<a href=\"{$twitter}\" class=\"x-author-social\" title=\"Visit the Twitter Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i> Twitter</a>" : '';
  $googleplus_output = ( $googleplus ) ? "<a href=\"{$googleplus}\" class=\"x-author-social\" title=\"Visit the Google+ Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i> Google+</a>" : '';
$instagram_output   = ( $instagram )   ? "<a href=\"{$instagram}\" class=\"x-author-social\" title=\"Visit the Instagram Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-instagram\" data-x-icon=\"\"></i> Instagram</a>" : '';
  $output = "<div {$id} class=\"{$class}\" {$style}>"
            . "<h6 class=\"h-about-the-author\">{$title}</h6>"
            . get_avatar( $author_id, 180 )
            . '<div class="x-author-info">'
              . "<h4 class=\"h-author mtn\"><a href=\"{$author_url}\">{$display_name}</a></h4>"
                . $facebook_output
                . $twitter_output
                . $googleplus_output
                . $instagram_output
              . "<p class=\"p-author mbn\">{$description}</p>"
            . '</div>'
          . '</div>';

  return $output;
}

function change_author_shortcode_to_v2() {
  remove_shortcode( 'x_author' );
  remove_shortcode( 'author' );
  add_shortcode( 'x_author', 'x_shortcode_author_v2' );
  add_shortcode( 'author', 'x_shortcode_author_v2' );
}
add_action('init', 'change_author_shortcode_to_v2');

function add_profile_instagram ( $profile_fields ) {

  $profile_fields['instagram'] = 'Instagram URL';

  return $profile_fields;
}


add_filter('user_contactmethods', 'add_profile_instagram');
// =============================================================================

// Author Link
// =============================================================================

if ( ! function_exists( 'x_ethos_entry_meta' ) ) :
  function x_ethos_entry_meta() {

      $author = ' by <a href="'.  get_author_posts_url(get_the_author_meta( 'ID' )) . '">' . get_the_author() . '</a></span>';

    $date = sprintf( '<span><time class="entry-date" datetime="%1$s">%2$s</time></span>',
      esc_attr( get_the_date( 'c' ) ),
      esc_html( get_the_date() )
    );

    if ( get_post_type() == 'x-portfolio' ) {
      if ( has_term( '', 'portfolio-category', NULL ) ) {
        $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
        $separator         = ', ';
        $categories_output = '';
        foreach ( $categories as $category ) {
          $categories_output .= '<a href="'
                              . get_term_link( $category->slug, 'portfolio-category' )
                              . '" title="'
                              . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                              . '"> '
                              . $category->name
                              . '</a>'
                              . $separator;
        }

        $categories_list = sprintf( '<span>In %s',
          trim( $categories_output, $separator )
        );
      } else {
        $categories_list = '';
      }
    } else {
      $categories        = get_the_category();
      $separator         = ', ';
      $categories_output = '';
      foreach ( $categories as $category ) {
        $categories_output .= '<a href="'
                            . get_category_link( $category->term_id )
                            . '" title="'
                            . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
                            . '"> '
                            . $category->name
                            . '</a>'
                            . $separator;
      }

      $categories_list = sprintf( '<span>In %s',
        trim( $categories_output, $separator )
      );
    }

 if ( comments_open() ) {
      $title  = get_the_title();
       $link = get_permalink() . '#disqus_thread';
      $number = get_comments_number();
      if ( $number == 0 ) {
        $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
          esc_url( $link ),
          esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
          __( 'Leave a Comment' , '__x__' )
        );
      } else if ( $number == 1 ) {
        $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
          esc_url( $link ),
          esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
          $number . ' ' . __( 'Comment' , '__x__' )
        );
      } else {
        $comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments">%3$s</a></span>',
          esc_url( $link ),
          esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
          $number . ' ' . __( 'Comments' , '__x__' )
        );
      }
    } else {
      $comments = '';
    }



    $post_type           = get_post_type();
    $post_type_post      = $post_type == 'post';
    $post_type_portfolio = $post_type == 'x-portfolio';
    $no_post_meta        = x_get_option( 'x_blog_enable_post_meta' ) == 0;
    $no_portfolio_meta   = x_get_option( 'x_portfolio_enable_post_meta' ) == 0;

    if ( $post_type_post && $no_post_meta || $post_type_portfolio && $no_portfolio_meta ) {
      return;
    } else {
      printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
        $categories_list,
        $author,
        $date,
        $comments
      );
    }

  }
endif;


// Show Author Box on Author Page
// =============================================================================

function add_author_meta() {
  if ( is_author() ) {
    $id = get_the_author_meta( 'ID' );
   echo do_shortcode('[x_author id="'.$id.'"]');
  }
}

add_action('x_before_view_global__index', 'add_author_meta');





//footer instagram
//=============================================================================
add_action('x_before_view_global__footer-widget-areas',  'my_footer_html_code');

function my_footer_html_code() { ?>

<div class="instagram-feed-footer"> <h4 style="text-align:center;"><a href="https://www.instagram.com/andthenwetried/" class="x-author-social" title="Visit the Instagram Profile for And Then We Tried" target="_blank"><i class="x-icon-instagram" data-x-icon=""></i>  Follow on Instagram</a></h4> <?php echo do_shortcode('[instagram-feed]'); ?></div>

<?php }


//Read More Button For Excerpt
function themprefix_excerpt_read_more_link($output) {
    global $post;
    
    return str_word_count( $output, 0 ) <= 10 ? $output : $output . ' <a href="' . get_permalink($post->ID) . '" class="more-link" title="Read More">Keep Reading <i class="x-icon x-icon-arrow-circle-right" data-x-icon="" aria-hidden="true"></i></a>';

}
add_filter( 'the_excerpt', 'themprefix_excerpt_read_more_link' );

Hi again,

Please find and remove the following piece of code:

// Read More Category
// =============================================================================

function excerpt_read_more_link($output) {
if ( !is_home() ) {
 global $post;
 return $output . '<a href="' . get_permalink() . '" class="more-link">' . __( 'Keep Reading ', '__x__' ) . '<i class="x-icon x-icon-arrow-circle-right" data-x-icon="" aria-hidden="true"></i></a>';
}
}
add_filter('the_excerpt', 'excerpt_read_more_link');

That should fix it, let us know how this goes!

that worked, thanks!

Glad we could help.

Cheers!