Site logo

Archived topic

"Read More" in case of no excerpt

4 replies · Started by Andreas on March 26, 2018

Viewing posts 1–5 of 5

Hello there,

How can I force to display the "Read more" link/button on archive pages in every case, even if the content is too short for an automatic excerpt and no <!--more--> tag exists in the post?

Best regards,
Andreas

Hi there,

You could try this (after turning off the built in read more):

add_action( 'generate_after_entry_content', 'tu_static_read_more_button' );
function tu_static_read_more_button() {
    ?>
    <p class="read-more-container">
        <a href="<?php the_permalink(); ?>" class="button">Read more</a>
    </p>
    <?php
}

It works! Thanks a lot.

Hi

This solution also adds the read more -function to the end of a single post. How can I remove it from single articles and only show it on archive pages / blogroll?

Try this instead:

add_action( 'generate_after_entry_content', 'tu_static_read_more_button' );
function tu_static_read_more_button() {
?>
    <?php if ( is_home() || is_archive() ) : ?>
        <p class="read-more-container">
            <a href="<?php the_permalink(); ?>" class="button">Read more</a>
        </p>
    <?php endif; ?>
<?php
}
This archived topic is closed to new replies.