• Sometimes I make long posts, which require a “read more”. So I use the “more” tag.

    However, I sometimes also make short posts — like 2 or 3 paragraphs, maybe just to link to another website. These posts do not require a “read more”, but it shows up anyway, thanks to the way the theme is set up. But if someone clicks on it… there will be no additional info, so it’s misleading.

    How do I make the “read more” only appear for the posts where I’ve specifically placed the more tag? And not appear for posts where I’ve not used it.

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Theme Author Silkalns

    (@silkalns)

    I already answered this question a while ago on our support forum and I hope you don’t mind that I will point you to that discussion.

    Thread Starter bgcyam

    (@bgcyam)

    Thanks! The first step was fine, but the second step is not working for me. I either get major errors (resulting in the whole site breaking), or just… nothing at all.

    Theme Author Silkalns

    (@silkalns)

    What error message do you get?

    Thread Starter bgcyam

    (@bgcyam)

    Okay, when I tried adding the new function to functions.php in the child theme, the Read Mores still did not appear. The top of the page showed the code instead: function sparkling_excerpt_more( $more ) { return ' ' . __('READ MORE', 'SPARKLING') . ''; } add_filter( 'excerpt_more', 'sparkling_excerpt_more' );"\

    So I thought maybe it was because that was the only code in my functions.php file. When I tried cloning the functions.php file & adding it to my child-theme folder (with the new code added), I got this:

    Fatal error: Cannot redeclare sparkling_content_width() (previously declared in /home/chimer/public_html/browngirlcomics.com/wp-content/themes/sparkling-child/functions.php:19) in /home/chimer/public_html/browngirlcomics.com/wp-content/themes/sparkling/functions.php on line 23

    At which point I added it to the parent function.php file. Fortunately, no errors appeared… but the read mores are still absent. :S

    The site is browngirlcomics dot com, by the way.

    Theme Author Silkalns

    (@silkalns)

    Clean up your entire Child Theme functions.php file and add this code instead:

    <?php 
    
    function sparkling_excerpt_more( $more ) {
      return ' <a class="read-more btn btn-default" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'sparkling') . '</a>';
    }
    add_filter( 'excerpt_more', 'sparkling_excerpt_more' );
    
     ?>

    You didn’t have opening and closing php tags to tags to the file, so you get the function printed as text in the website header.

    Thread Starter bgcyam

    (@bgcyam)

    Thanks so much for all your help… sadly I still can’t get this to work. Not sure where I am going wrong.

    Since I am not using function.php in my child theme for anything else, I just created a new php file & placed your above code 9with the open/close tags — oops) in it, before uploading it to the child theme folder on my server. Unfortunately, the Read Mores still did not show up for the relevant posts. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Read more to appear only when I use the more tag’ is closed to new replies.