WordPress.org

Ready to get started?Download WordPress

Forums

How to Add a "Read More" link? (7 posts)

  1. KristjanT
    Member
    Posted 1 year ago #

    Hi! After spending days looking for a responsive template that would support both regular post and gallery type posts, I found Ascetica. It looks absolutely stunning and most importantly it works great on mobile devices. Which is really important to me as my new site is about Android phones and applications.

    However, that template is missing something I'd really like. A "Read More" or "Continue" link at the end of post excerpts.

    Is there anyway I could add that by editing the code? If so, can somebody help me with that? I don't know much about coding.

    Here's the site: droidologist.com

    Thank You!

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

  3. vtxyzzy
    Member
    Posted 1 year ago #

    You should create a Child theme to make your changes. If you do not, all of your changes will be lost if you update your theme.

    You can add the following filter in functions.php:

    function mam_excerpt_more( $more ) {
       global $post;
       $permalink = get_permalink($post->ID);
       return "<a href='$permalink' > Read More </a>";
    }
    add_filter('excerpt_more','mam_excerpt_more',99);

    If you do modify the Ascetica functions.php, add these lines just before this line:

    /* Load the core theme framework. */
  4. KristjanT
    Member
    Posted 1 year ago #

    I got a child theme and tried out the code vtxyzzy gave. It worked fine. However, it deleted the 3 dots from the end of the excerpts, and I didn't like that. So I deleted the code, updated the file and now I get an error message: Parse error: syntax error, unexpected $end in /mounted-storage/home156/sub015/sc82788-UZZI/droidologist.com/wp-content/themes/ascetica-child/functions.php on line 25

    I pressed back and performed a good old ctrl+z and the code came back.

    However, it didn't get rid off the error message.

    I can't view any pages of my site. Not even move around on the dashboard.

    Can anyone help?

  5. vtxyzzy
    Member
    Posted 1 year ago #

    You can use ftp or a File Manager from your hosting service to edit the functions.php and correct the error.

  6. KristjanT
    Member
    Posted 1 year ago #

    Thanks! I managed to fix the error.

    What about the other problem? I feel like the "..." are necessary at the end of excerpts. I could make them a part of the link by simply renaming "Read More" to "...Read More", however that doesn't look as good.

    Can anyone help?

  7. vtxyzzy
    Member
    Posted 1 year ago #

    Just change the ' Read More ' in this line to whatever you want:

    return "<a href='$permalink' > Read More </a>";

Topic Closed

This topic has been closed to new replies.

About this Topic