Celebrating 7 Years! Get up to $30 off GeneratePress Premium!

[Support request] "Read More" in case of no excerpt

Home Forums Support [Support request] "Read More" in case of no excerpt

Home Forums Support "Read More" in case of no excerpt

  • This topic has 4 replies, 4 voices, and was last updated 3 years ago by Leo.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #532028
    Andreas

    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

    GeneratePress 2.0.2
    #533006
    Tom
    Lead Developer
    Lead Developer

    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
    }
    #533344
    Andreas

    It works! Thanks a lot.

    #576916
    Sami

    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?

    #577275
    Leo
    Staff
    Customer Support

    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
    }
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.