Adding "Post Title" to Read More links

Community Forums Forums Design Tips and Tricks Adding "Post Title" to Read More links

This topic is: resolved

This topic contains 11 replies, has 2 voices, and was last updated by  Stewart 1 year, 2 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #51924

    middayminer
    Participant
    Post count: 72

    Hi guys, trying to tweak my Read More links here.

    This is what I’ve been using in custom code, just the normal stuff:

    
    //* Modify the WordPress read more link
    add_filter( 'the_content_more_link', 'custom_read_more_link' );
    function custom_read_more_link() {
    	return '<a class="more-link" href="' . get_permalink() . '">Continue Reading »</a>';
    }
    

    I’ve googled up a few snippets for adding the post title but they all whitescreen in some form, anyone know the correct way of making this work?

    see this website’s read more links for an example:

    http://viget.com/extend

    #52005

    Stewart
    Participant
    Post count: 156

    Hi,

    Try adding on your filter line ‘get_the_content_more_link’ instead of ‘the_content_more_link’.

    [php]
    //* Modify the WordPress read more link
    add_filter( ‘get_the_content_more_link’, ‘custom_read_more_link’ );
    function custom_read_more_link() {
    return ‘… Continue Reading »‘;
    }
    [/php]

    Works for me using the you code with the small change.

    Hope this helps
    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

    #52027

    middayminer
    Participant
    Post count: 72

    Thanks for replying Stewart!

    I tried the modification you suggested, but what it does for me is replace ‘Continue Reading »’ with ‘[Read more...]‘, which I surmise is the default?

    I’m trying to make it so that the read more function will call and get the post title dynamically, like the ‘Automatically display the post title in more links’ section here

    http://digwp.com/2010/01/wordpress-more-tag-tricks/

    The code there doesn’t work, of course.

    #52031

    Stewart
    Participant
    Post count: 156

    Ok gotcha, so if I’m right this time you’re trying to get the link to show for example:

    Continue Reading >> The Post Title

    If I’m correct in what you’re trying to do (which I’m never right ;p) try this:

    [php]
    //* Modify the WordPress read more link
    add_filter( ‘get_the_content_more_link’, ‘custom_read_more_link’ );
    function custom_read_more_link() {
    return ‘Continue Reading » ‘ . get_the_title() . ‘‘;
    }
    [/php]

    What this should do it change the default “Read More” to “Continue Reading » Example Post Title

    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

    #52035

    Stewart
    Participant
    Post count: 156

    If I’m correct in what you’re trying to do (which I’m never right ;p) try this:

    [php]
    //* Modify the WordPress read more link
    add_filter( ‘get_the_content_more_link’, ‘custom_read_more_link’ );
    function custom_read_more_link() {
    return ‘Continue Reading » ‘ . get_the_title() . ‘‘;
    }
    [/php]

    What this should do it change the default “Read More” to “Continue Reading » Example Post Title

    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

    #52042

    middayminer
    Participant
    Post count: 72

    You understand perfectly well, no worries there.

    The new code looks great, but it still reverts me back to [Read More...] :(

    For reference, my current customisation is based off Brian Gardner’s snippet

    http://www.briangardner.com/code/customize-read-more-link/

    Unfortunately googling seems to turn up absolutely no pertinent results for genesis regarding this.

    #52047

    Stewart
    Participant
    Post count: 156

    So after adding the snippet to your functions.php file its still showing just [Read More..]?

    Thats strange, just a thought I would check the rest of your theme code, maybe the theme is already using the filter somewhere else and its overriding?

    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

    #52059

    middayminer
    Participant
    Post count: 72

    I honestly doubt it, Stewart. I’ve only ever modified the read more function through custom code settings since it works fine from there, and the directly added code in my functions.php is only comprised of stuff I barely understand that wouldn’t work otherwise. :)

    Also, I tried directly adding the latest suggestion to functions.php(same result), but also noticed that it would whitescreen if custom code also called the read more function(I forgot to revert functions.php, making it two calls at once), so in my limited understanding I believe we can safely rule out a conflict. Perhaps the code is getting the default setting and then not applying the text mod or post title addition?

    #52098

    Stewart
    Participant
    Post count: 156
    This reply has been marked as private.
    #52109

    middayminer
    Participant
    Post count: 72

    That’s a really generous offer but I think I’ve troubled you enough today, Stewart. I’d rather not take up your time tomorrow as well! :) I’m sending a ticket to tech support, just hope they won’t link me to the forums this time…

    #52125

    middayminer
    Participant
    Post count: 72

    Solved it! Support wasn’t much help either, telling me that the code would have to be written specifically for my site.

    They did say the function was not genesis specific, so I just checked the codex and sort of winged it until it worked.

    
    
    //* Modify the WordPress read more link
    add_filter( 'the_content_more_link', 'custom_read_more_link' );
    function custom_read_more_link() {
    	return '<a href="' . get_permalink() . '">» Continue reading "' . get_the_title() . '" </a>';
    }
    
    

    Yeah, all it took was the addition of ‘ . get the title() . ‘

    Not sure how that makes it site specific, but progress is progress.

    #52126

    Stewart
    Participant
    Post count: 156

    Nice, Im glad you sorted it :)

    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

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

The topic ‘Adding "Post Title" to Read More links’ is closed to new replies.