• Resolved myladeybugg

    (@myladeybugg)


    I am working on a child twentytwelve theme and am trying to replace […] with a read more link, but can’t seem to get it to work.

    This is what I am using in my child’s functions.php

    /* REPLACE [...] GET_EXCERPT WITH LINK */
    function custom_excerpt($text)
    {
        return str_replace('[...]', '... <a style="font-weight:bold" href="'. get_permalink($post->ID) . '">' . '→ Read More' . '</a>', $text);
    }
    add_filter('the_excerpt', 'custom_excerpt');

    Any ideas on why this isn’t working? Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter myladeybugg

    (@myladeybugg)

    Here is the fix –

    function new_excerpt_more( $more ) {
    	return '... <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">→ Read More</a>';
    }
    add_filter( 'excerpt_more', 'new_excerpt_more' );

    So, does the above “fix” mean, I copy all of the above code and put it in my post somewhere? Or do I place it somewhere else in my dashboard?
    function new_excerpt_more( $more ) {
    return ‘… → Read More‘;
    }
    add_filter( ‘excerpt_more’, ‘new_excerpt_more’ );

    I am trying to replace the {…} with an active link to the rest of the post also. I’m a very new WordPress user so this is all new to me. Thanks for your help!

    Thread Starter myladeybugg

    (@myladeybugg)

    @dennisgunderson

    You want to place the following code in your child theme’s functions.php file in between your php tags.

    The code above should replace the […] with “Read More” that links to the post.

    Thanks myladeybugg! I will try that with my next post. I’m afraid to try it with my preceding ones, as they are set up to show the whole post now and not abbreviated. I can see under “manage themes” that the person who set up my blog set it up with “education child theme.” Is “functions.php in there somewhere? I’m not spotting that. I’ve heard of .php but have never seen anything about it in my dashboard – maybe I haven’t hunted far enough yet.

    Thread Starter myladeybugg

    (@myladeybugg)

    You’re welcome.

    1. You mention your older posts are not set up to be abbreviated. Have you already set this up? This code does not abbreviate your post for you.

    2. You will only have a functions.php if the person that set you up added one to the theme. If you are looking through the editor in your admin panel it’s called Theme Functions.

    If there is not one, you can add a file called functions.php, and the code I have above between php tags.

    <?php
    CODE HERE
    ?>

    You’re very knowledgeable and helpful – thanks! You’re right, mine appears to be set up without a functions.php
    I hope I’m not being too much of a bother… I’d like to add the functions.php and put the code between – but I don’t know where to insert it. I’m afraid I need a bonafide tutor who walks me through this stuff. ?? I may have to pay someone to take time on the phone.

    Thread Starter myladeybugg

    (@myladeybugg)

    If you want any further help from me, let me know. ??

    Thanks! Well, I did download WordPress 3.8 today. And was told by a friend that the Genesis tab has a custom codes slot where I can enter the .php code in that you gave me. But neither she nor I could find that slot to enter it. Would you know where it is? Thank you again for your kind help.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Replacing ellipsis with link’ is closed to new replies.