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

  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?

  • 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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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