read more button even if there is no Excerpt

  • Tangerine85

    #3528

    Hi.

    I was wondering if it is possible to add a read more button even if the post has no excerpt. I have added custom fields to a particular type of post so all of them have additional information but not necessarily a manual excerpt.

    I need all the posts to display the button when the search results are displayed.

    Thank you!

    Prasanna SP

    #24703

    Add <!--more--> tag at the end of each post. This should add a read more button at the end of excerpts eventhough there is no more content.

    Make sure you’ve selected “Show more button for Manual Excerpt” in Graphene Options –> Display –> Excerpt Display Options

    Tangerine85

    #24704

    That does not work. I don’t know why

    Is there a way of doing it with a function on the child theme functions.php?

    something like this

    $more_link_text = __( 'Ver más »', 'graphene' );
    return '</p><p><a href="'.get_permalink().'">'.$more_link_text.'</a>';

    maybe conditioned to a particular type of post?

    Thanks so much

    Prasanna SP

    #24705

    Please put your code between backtics. I’ve corrected your comment above.

    Tangerine85

    #24706

    Sorry, I did not know about the backticks, its corrected now

    Prasanna SP

    #24707

    You don’t need to add backtics to each line. Just one at the beginning of the code and one at the end. I’ve corrected it again! 🙂

    Tangerine85

    #24708

    I have this post type, named “sm-location”

    and there are 31500 posts.

    I need them all to be listed with a “Continue reading” button

    thats why I thought maybe it could be done with a funtion in the child theme that would affect all of these types of post. even if they have no excerpt.

    Prasanna SP

    #24709

    It’s too late here. I’ll get back you tomorrow. Or, someone else may help you now.

    Admin

    Syahir Hakim

    #24710

    Try this:

    <?php
    function my_custom_more_button(){
    if ( get_post_type() != 'sm-location' || is_singular() ) return;

    echo graphene_continue_reading_link();
    }
    add_action( 'graphene_after_post_content', 'my_custom_more_button' );
    ?>

    Tangerine85

    #24711

    Thanks! It works great.

    But for some reason, even though I disabled the “Show more button for Manual Excerpt”, it shows TWO “continue reading” buttons…for the posts that do have an excerpt

    Any idea why?

Viewing 10 posts - 1 through 10 (of 12 total)

You must be logged in to reply to this topic.