Read more excerpt not showing

I have this code in my functions php:

load_theme_textdomain( '__x__', X_TEMPLATE_PATH . '/framework/lang' );

// JavaScript Document
// Changing excerpt more
   function new_excerpt_more($more) {
   global $post;
   return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>';
   }
   add_filter('excerpt_more', 'new_excerpt_more');
   /* Fix "Missing Author" and "Missing Updated" issue - START */
function add_suf_hatom_data($content) {
	$t      = get_the_modified_time('F jS, Y');
	$author = get_the_author();
	$title  = get_the_title();
	if (is_home() || is_singular() || is_archive() ) {
	$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
	}
	return $content;
}
add_filter('the_content', 'add_suf_hatom_data');
/* Fix "Missing Author" and "Missing Updated" issue - END */

function exclude_jetpack_related_from_portfolio( $options ) {
    if ( 'jetpack_portfolio' == get_post_type() ) {
        $options['enabled'] = false;
    }
    return $options;
}
 
add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_portfolio' );

add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );

 function x_ethos_featured_index() {

    ?>

      <a href="#" class="entry-thumb<?php echo $index_featured_layout_class; echo $index_featured_size_class; ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>"> </a>

    <?php

  }

The top part:

   function new_excerpt_more($more) {
   global $post;
   return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>';
   }
   add_filter('excerpt_more', 'new_excerpt_more');

Was added to show “read more” on the blog index page here:

But after the last update, its stopped showing, do I need to update that code?

Actually, its not because of the update, I was trying to fix the google errors for the Hentry with this code:

function add_suf_hatom_data($content) {
	$t      = get_the_modified_time('F jS, Y');
	$author = get_the_author();
	$title  = get_the_title();
	if (is_home() || is_singular() || is_archive() ) {
	$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
	}
	return $content;
}
add_filter('the_content', 'add_suf_hatom_data');

I have taken this out, and the read more is back. But I still want the hentry to be fixed, how can I do both?

Hi @logoglo,

Thanks for reaching out.

Would you mind providing the entire code of your child theme’s functions.php? That HENTRY code is attached to the the_content filter where used on single posts where it’s not related to the excerpt. And it’s excerpt that uses the read more, hence, it should have no effect.

But, you can try removing the part || is_archive() from that code and test it again.

Thanks!

Hmm, took the archive bit out, but it still doesnt work.

Here is the full php:

<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Theme functions for X. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Boot Registry // 02. Bootstrap Class // 03. Content Width // 04. Localization // ============================================================================= // Boot Registry // ============================================================================= function x_boot_registry() { return array( 'preinit' => array( 'functions/helpers', 'functions/thumbnails', 'functions/setup', 'tco/tco', 'legacy/setup', 'functions/fonts', 'functions/custom-sidebars', 'functions/portfolio', 'functions/plugins/setup', 'functions/updates/class-theme-updater', 'functions/updates/class-plugin-updater' ), 'init' => array(), 'front_end' => array( 'functions/frontend/view-routing', 'functions/frontend/styles', 'functions/frontend/scripts', 'functions/frontend/content', 'functions/frontend/classes', 'functions/frontend/meta', 'functions/frontend/integrity', 'functions/frontend/renew', 'functions/frontend/icon', 'functions/frontend/ethos', 'functions/frontend/social', 'functions/frontend/breadcrumbs', 'functions/frontend/pagination', 'functions/frontend/featured', 'functions/frontend/conditionals', ), 'logged_in' => array( ), 'admin' => array( 'functions/admin/class-validation', 'functions/admin/class-validation-updates', 'functions/admin/class-validation-theme-options-manager', 'functions/admin/class-validation-extensions', 'functions/admin/setup', 'functions/admin/customizer', 'functions/admin/meta-boxes', 'functions/admin/meta-entries', 'functions/admin/taxonomies' ), 'app_init' => array( 'functions/theme-options', ), 'ajax' => array() ); } // Bootstrap Class // ============================================================================= class X_Bootstrap { private static $instance; protected $registry = array(); protected $theme_option_defaults = array(); public function boot() { // Define Path / URL Constants // --------------------------- define( 'X_TEMPLATE_PATH', get_template_directory() ); define( 'X_TEMPLATE_URL', get_template_directory_uri() ); // Preboot // ------- $x_boot_files = glob( X_TEMPLATE_PATH . '/framework/load/*.php' ); sort( $x_boot_files ); foreach ( $x_boot_files as $filename ) { $file = basename( $filename, '.php' ); if ( file_exists( $filename ) && apply_filters( "x_pre_boot_$file", '__return_true' ) ) { require_once( $filename ); } } // Set Asset Revision Constant (For Cache Busting) // ----------------------------------------------- define( 'X_ASSET_REV', X_VERSION ); // Preinit // -------- $this->registry = x_boot_registry(); $this->boot_context('preinit'); // Theme Option Defaults // --------------------- $this->theme_option_defaults = include X_TEMPLATE_PATH . '/framework/data/option-defaults.php'; if ( is_admin() ) { $this->boot_context('admin'); } add_action( 'init', array( $this, 'init' ) ); add_action( 'admin_init', array( $this, 'ajax_init' ) ); add_action( 'cornerstone_before_boot_app', array( $this, 'app_init' ) ); add_action( 'cornerstone_before_custom_endpoint', array( $this, 'app_init' ) ); add_action( 'cornerstone_before_admin_ajax', array( $this, 'app_init' ) ); add_action( 'cornerstone_before_admin_ajax', array( $this, 'ajax_init' ) ); add_action( 'cornerstone_before_custom_endpoint', array( $this, 'ajax_init' ) ); } public function init() { $this->boot_context('init'); if ( ! is_admin() ) { $this->boot_context('front_end'); } if ( is_user_logged_in() ) { $this->boot_context('logged_in'); } } public function admin_init() { $this->boot_context('admin_init'); } public function app_init() { $this->boot_context('app_init'); } public function ajax_init() { if ( defined( 'DOING_AJAX' ) ) { $this->boot_context('ajax'); } } public function boot_context( $context ) { if ( ! isset( $this->registry[$context] ) ) { return; } foreach ( $this->registry[$context] as $file ) { require_once( X_TEMPLATE_PATH . "/framework/$file.php" ); } do_action( 'x_boot_' . $context ); } public static function instance() { if ( ! isset( self::$instance ) ) { self::$instance = new X_Bootstrap(); } return self::$instance; } public function get_theme_option_defaults() { return $this->theme_option_defaults; } public function get_theme_option_default( $key ) { return isset( $this->theme_option_defaults[$key]) ? $this->theme_option_defaults[$key] : false; } } function x_bootstrap() { return X_Bootstrap::instance(); } x_bootstrap()->boot(); // Content Width // ============================================================================= if ( ! isset( $content_width ) ) : $stack = x_get_stack(); switch ( $stack ) { case 'integrity' : $content_width = x_post_thumbnail_width() - 120; break; case 'renew' : $content_width = x_post_thumbnail_width(); break; case 'icon' : $content_width = x_post_thumbnail_width(); break; case 'ethos' : $content_width = x_post_thumbnail_width(); break; } endif; // Localization // ============================================================================= load_theme_textdomain( '__x__', X_TEMPLATE_PATH . '/framework/lang' ); function new_excerpt_more($more) { global $post; return '… ' . 'Read More »' . ''; } add_filter('excerpt_more', 'new_excerpt_more'); function exclude_jetpack_related_from_portfolio( $options ) { if ( 'jetpack_portfolio' == get_post_type() ) { $options['enabled'] = false; } return $options; } add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_portfolio' ); add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' ); function x_ethos_featured_index() { ?>
  <a href="#" class="entry-thumb<?php echo $index_featured_layout_class; echo $index_featured_size_class; ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>"> </a>

<?php

}

Hello There,

Thanks for updating in! When I checked your site, it seems that you are not using a child theme and this is why you have added the custom code in the X theme’s functions.php file. We do not recommend adding any code in this file because every time when there are theme updates, this file will be overwritten thus your changes will be gone. This is the logical reason why you are back to square one.

Since what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released.

After the child theme is set up, please add the following code in your child theme’s functions.php file

// JavaScript Document
// Changing excerpt more
   function new_excerpt_more($more) {
   global $post;
   return '… <a href="'. get_permalink($post->ID) . '">' . 'Read More &raquo;' . '</a>';
   }
   add_filter('excerpt_more', 'new_excerpt_more');
   /* Fix "Missing Author" and "Missing Updated" issue - START */
function add_suf_hatom_data($content) {
	$t      = get_the_modified_time('F jS, Y');
	$author = get_the_author();
	$title  = get_the_title();
	if (is_home() || is_singular() || is_archive() ) {
	$content .= '<div class="hatom-extra" style="display:none;visibility:hidden;"><span class="entry-title">'.$title.'</span> was last modified: <span class="updated"> '.$t.'</span> by <span class="author vcard"><span class="fn">'.$author.'</span></span></div>';
	}
	return $content;
}
add_filter('the_content', 'add_suf_hatom_data');
/* Fix "Missing Author" and "Missing Updated" issue - END */

function exclude_jetpack_related_from_portfolio( $options ) {
    if ( 'jetpack_portfolio' == get_post_type() ) {
        $options['enabled'] = false;
    }
    return $options;
}
 
add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_portfolio' );

add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );

 function x_ethos_featured_index() {

    ?>

      <a href="#" class="entry-thumb<?php echo $index_featured_layout_class; echo $index_featured_size_class; ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>"> </a>

    <?php

  }

Hope this helps.

Yeha, I know, it was before I knew what I was doing, but when I add a child theme now, it messes certain things up…

I added the above code, but its still not working.

Hello There,

Would you mind providing us access to your site so that we can take a closer look and investigate the codes further?

Thank you in advance.

Sure, thanks, see secure note.

Hello There,

I have logged in to your site. I cannot do anything since I cannot save my changes in your functions.php file.

I wanted to remove the custom php codes to test for plugin conflicts. Could you please install a child theme first? We can transfer those php codes in your child theme’s functions.php file and then re install X theme to make sure that there are no corrupted theme files. If you can give us FTP access, we can re install the X theme and install a child theme for you.

Please let us know.

I have installed the child theme, but it wont let me edit the functions.php there either, hangs.

Its something to do with the hentry code, when I take that out, the excerpts come back.

Also, its removing the excerpt, and adding this:

“Start your own business. The easy way – a basic guide. was last modified: July 24th, 2018 by Gary”

It should only show the excerpt

I have removed that bit of code for now, I would rather have a working site, than to get rid of the hentry error, but please, look into a solution. Thanks.

Update: I took the hentry code out, but now the “read more” isnt working, even without.

Hello There,

Please update the contents of your child theme’s functions.php file and use this instead:



// 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">' . __( 'Read More', '__x__' ) . '</a></div>';
    } else if ( $stack == 'renew' ) {
      return ' ... <a href="' . get_permalink() . '" class="more-link">' . __( 'Read More', '__x__' ) . '</a>';
    } else if ( $stack == 'icon' ) {
      return ' ...';
    } else if ( $stack == 'ethos' ) {
      return ' ...<a href="' . get_permalink() . '" class="more-link">' . __( 'Read More &raquo;', '__x__' ) . '</a>';
    }

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


/* Fix "Missing Author" and "Missing Updated" issue - START */
// =============================================================================
add_filter( 'the_content', 'custom_author_code');
function custom_author_code($content) {
   if (is_singular() || is_single()) {
      return $content . 
      '<div class="hatom-extra"><span class="title">'. get_the_title() .'</span> was last modified: <span class="updated"> '. get_the_modified_time('F jS, Y') .'</span> by <span class="author vcard"><span class="fn">'. get_the_author() .'</span></span></div>' ;
   } else {
      return $content;
   }
}
/* Fix "Missing Author" and "Missing Updated" issue - END */


// =============================================================================
function exclude_jetpack_related_from_portfolio( $options ) {
    if ( 'jetpack_portfolio' == get_post_type() ) {
        $options['enabled'] = false;
    }
    return $options;
}
add_filter( 'jetpack_relatedposts_filter_options', 'exclude_jetpack_related_from_portfolio' );


// =============================================================================
add_filter( 'woocommerce_enqueue_styles', '__return_empty_array' );


// =============================================================================
function x_ethos_featured_index() { ?>

    <a href="#" class="entry-thumb<?php echo $index_featured_layout_class; echo $index_featured_size_class; ?>" style="<?php echo x_ethos_entry_cover_background_image_style(); ?>"> </a>

<?php }
 

We would loved to know if this has work for you. Thank you.

1 Like

Perfect! thanks guys!

You’re welcome!

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