Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding "Post Title" to Read More links
- This topic has 11 replies, 2 voices, and was last updated 10 years, 8 months ago by Stewart.
-
AuthorPosts
-
July 22, 2013 at 3:44 pm #51924middayminerMember
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/extendJuly 23, 2013 at 5:02 am #52005StewartMemberHi,
Try adding on your filter line 'get_the_content_more_link' instead of 'the_content_more_link'.
//* Modify the WordPress read more link add_filter( 'get_the_content_more_link', 'custom_read_more_link' ); function custom_read_more_link() { return '... <a>Continue Reading »</a>'; }
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 TwitterJuly 23, 2013 at 6:53 am #52027middayminerMemberThanks 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.
July 23, 2013 at 7:14 am #52031StewartMemberOk 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:
//* Modify the WordPress read more link add_filter( 'get_the_content_more_link', 'custom_read_more_link' ); function custom_read_more_link() { return '<a>Continue Reading » ' . get_the_title() . '</a>'; }
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 TwitterJuly 23, 2013 at 7:17 am #52035StewartMemberIf I'm correct in what you're trying to do (which I'm never right ;p) try this:
//* Modify the WordPress read more link add_filter( 'get_the_content_more_link', 'custom_read_more_link' ); function custom_read_more_link() { return '<a>Continue Reading » ' . get_the_title() . '</a>'; }
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 TwitterJuly 23, 2013 at 7:37 am #52042middayminerMemberYou 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.
July 23, 2013 at 7:51 am #52047StewartMemberSo 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 TwitterJuly 23, 2013 at 8:38 am #52059middayminerMemberI 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?
July 23, 2013 at 11:24 am #52098StewartMemberThis reply has been marked as private.July 23, 2013 at 12:16 pm #52109middayminerMemberThat'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...
July 23, 2013 at 2:07 pm #52125middayminerMemberSolved 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.
July 23, 2013 at 2:23 pm #52126StewartMemberNice, Im glad you sorted it 🙂
Stewart
WordPress Developer – Need help upgrading to Genesis 2.0? – My Blog
Follow me on Twitter -
AuthorPosts
- The topic ‘Adding "Post Title" to Read More links’ is closed to new replies.