You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Underscores.me中显示并编辑博客列表页的「阅读更多」按钮

Hey there! Let's get that "Read More" button working properly on your Underscores.me blog list page. The weird [...] you're seeing is the default placeholder from WordPress' excerpt function—we can fix this by tweaking your content.php file correctly. Here's how:

Step 1: Locate the excerpt section in content.php

Open up your theme's content.php file. Look for a line that looks like this:

<?php the_excerpt(); ?>

This is what's generating the plain text excerpt with the default ellipsis. We'll replace this with code that adds a proper "Read More" link.

Step 2: Replace with a custom excerpt + Read More button

You have two solid options here:

Option 1: Use WordPress' built-in content truncation (with automatic "Read More")

Replace the the_excerpt() line with this code:

<?php
the_content( sprintf(
    wp_kses(
        __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'your-theme-slug' ),
        array(
            'span' => array(
                'class' => array(),
            ),
        )
    ),
    wp_kses_post( get_the_title() )
) );
?>

Make sure to replace your-theme-slug with the actual slug of your Underscores theme (this is the name you chose when generating the theme).

If you manually add the <!--more--> tag inside your blog posts, this will truncate the content exactly at that tag. If not, it will use the default excerpt length you set in Settings > Reading in your WordPress dashboard.

Option 2: Manual excerpt with a custom button (more control)

If you want full control over the excerpt length and button styling, use this instead:

<?php
// Trim content to 55 words (adjust number as needed)
$custom_excerpt = wp_trim_words( get_the_content(), 55, '' );
echo $custom_excerpt;
?>
<a href="<?php the_permalink(); ?>" class="read-more-btn"><?php _e( 'Read More', 'your-theme-slug' ); ?></a>

You can adjust the 55 to any word count you want, and style the .read-more-btn class in your theme's CSS to match your design.

Step 3: Double-check the template context

Make sure you're modifying the section of content.php that applies to the blog list page. Underscores often wraps the content display in a conditional like:

if ( is_home() || is_archive() || is_search() ) :
    // Excerpt/Read More code goes here
endif;

Ensure your changes are inside this block so they only affect the list view, not single posts.

That should replace the weird ellipsis with a functional "Read More" link that takes users to the full post. Let me know if you hit any snags!

内容的提问来源于stack exchange,提问作者Silvana Junior

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:56:15