Tech Hive

Blog on Wordpress, Design, Usability, Accessibility and Standards

  • Content
  • Sidebar
  • Footer
  • « The Great IE 6 Hack
  • Redesigned »

Appending the title of the post in Read More links for Wordpress

Leave a response | Trackback |
Tags: tips, WordPress

One of the guidelines in usability is that you should provide only one way that will lead them to a certain action. For example, if someone sees 2 option buttons, chances are that they might think that each option button does separate tasks when in fact their functions are the same. Also, we have to make sure that the links are descriptive enough and if not, then we should provide a title for the link so when a user hovers over it then they’ll know where the link will take them.

On a similar note, accessibility advocates encourages people to use unique name for every link that we use on a page (kinda like what I was saying before only have a different reason), meaning countless “Read more of this entry” is not really the best practice because you’re using the same text over and over and these texts are leading the user to different pages.

I was looking for a way to add that in <?php the_content(); ?> tag in wordpress before but I couldn’t do it. What I did then was append the the_title(); within the_content(); so it looked like this –

<?php the_content('Read more of ' . the_title() . ' & raquo;' ?>

The problem though is that it does echo the “Read more of” but the title is no where in sight! I was so ready to find a way to make it show by hacking away through function.php, thankfully I remembered to check the_content page in the codex first.

What I should’ve done in the first place is to add parameters to the the_title() tag so it will show like this –

<?php the_content('Read more of ' . the_title('', '', false)) ?>

This follows the same parameter as the the_title(); template tag.

Parameters

before
(string) Text to place before the title. Defaults to ”.

after
(string) Text to place after the title. Defaults to ”.

display
(Boolean) Display the title (TRUE) or return it for use in PHP (FALSE). Defaults to TRUE.

So you may use it like this:

<?php the_content('Read more of ' . the_title('&ldquo ;', '&rdquo ; &raquo ;', false)) ?>

So it will echo as Read more of “Title of the Post” ».

3 Responses to “Appending the title of the post in Read More links for Wordpress”

  1. Jeric Peña May 9, 2008 at 11:44 pm

    Thanks for the tip! I’ll use this on my blog besides, I don’t want to rank high on SERPS when searched the keyword “read more…”

  2. Mae May 10, 2008 at 3:00 am

    hehe thanks Jeric! Glad I was of any help to you :)

  3. Chris Osborne July 20, 2008 at 6:35 am

    I had this working before, but lost it when I switched themes. Thanks for having this in such an easy to follow format. I’ve never liked having what looked like the same link going to different places.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Pages

  • About the Author
  • Archives
  • Contact
  • Site Map

Post a job. Find one. authenticjobs.com
Come in, we're hiring

Full-time and freelance job opportunities available at Authentic Jobs:

Post a job and reach web professionals everywhere.

Archives

  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007

Categories

  • Accessibility
  • CSS Tips
  • Gmail
  • HTML
  • Online Finds
  • Online Tools
  • Tutorial
  • Updates
  • Usability
  • WordPress
  • Wordpress Themes

Tech Hive is proudly powered by WordPress
Spartan by Mae Paulino, a Filipina Web Designer