WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

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.