Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a blog page setup to list posts. The "Read More" link is added by

 <?php
  global $more;
  $more = 0; 

  the_content('<a href="#" class="button">Read More</a>'); ?>

How do i add the_permalink in where the "#" is without breaking the php?

share|improve this question
    
This use of the_content() is not very clean : only the link text should be specified here, without HTML tags. WP might remove the <a> tags. Could you check what outputs exactly in the source code ? Also, the "Read More" link may be handled by javascript in your theme (it's the only reason I see to put a # as the link source), be sure to check this as well. –  Fabien Quatravaux Jul 1 '13 at 2:45
add comment

1 Answer

Use get_permalink. Otherwise this is basically a PHP string concatenation question.

the_content('<a href="'.get_permalink().'" class="button">Read More</a>');
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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