I have the following in functions.php:

function twentyten_continue_reading_link() {
global $id;
return ' <span class="readmore"><a href="'. get_permalink($id) . '" title="' . the_title_attribute( array('echo' => 0, 'before' => 'Permalink to: ', 'after' => '')) . the_title() . '">' . __( 'Read More &#187;', 'twentyten' ) . '</a></span>';

which creates a "Read More" link after an excerpt with a title attribute.

I want to do the same thing in another part of the site, but the code for this 'Read More' link is different (see below). Since it's a php echo statement the same syntax won't work and I don't know how to translate what I have above to work in the situation below. I want to keep the href= $permalist[$j], but add a title attribute after it.

echo "<p class=\"readmore\"><a href=\"$permalist[$j]\">Read More &#187;</a></p>";

1 Answer 1


Not exactly wordpress question, more of a php but -

The syntax for echo is quit simple : You start with a quotation mark, and close with a quotation mark. But since INSIDE the HTML we also need quotation marks , we separate them by using the single ' for PHP and the double " for HTML. every time you have a php function, command, or variable, you should close the single quotation mark, place a DOT . and also put a dot . after, and re-open the single quotation mark if needed. close all with semicolumn

So it would look like this :

echo ' <mytag class=" ' . $phpvariable . ' " title = " continueHtml " ' ;

in your case :

echo '<p class=\"readmore\"><a href=' . $permalist[$j] . ' title="your title" >Read More &#187;</a></p>';


    echo "<h2><a href=\"$permalist[$j]\" >$titlelist[$j]</a></h2>";

 echo '<h2><a href="' . $permalist[$j] . '"/>' . $titlelist[$j] . '</a></h2>';

I am not familiar with permalist[$j] - does it being produced by you in any manner ? or did you mean permalink ? or are you using some kind of plugin that produces it ?


Using your code above, just change the syntax, and use the_title_attribute():

echo '<p class="readmore"><a href="' . $permalist[$j] . '" title="' . the_title_attribute( array( 'echo' => 0 ) ) . '">Read More &#187;</a></p>.;
  • Thanks for your help. permalist[$j] is a variable defined in the plugin (it's the permalink to the active slide in the content slider). I followed your suggestion but now the title attribute is displaying as "' . the_title_attribute( array('echo' => 0, 'before' => 'Permalink to: ', 'after' => '')) . the_title() . '" -- that code actually displays as the link title on hover. What am I doing wrong? Do I need to define . the_title_attribute . somewhere in the code before I use it?
    – Sarah
    Feb 19, 2012 at 18:23
  • can you please paste your whole code (relevant part)
    – krembo99
    Feb 20, 2012 at 13:58
  • 1
    See edited answer for example usage of the_title_attribute() in your code. Feb 20, 2012 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.