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.

Hi I have a custom post type that i've truncated on the archives pages using this:

function limit_the_content($content){
  $word_limit = 35;
  $words = explode(' ', $content);
  return implode(' ', array_slice($words, 0, $word_limit));
}

How would I add a read more and a link to the end of each post.

Thanks in advance.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You could add a link manually like:

<a href="<?php echo get_permalink($post->ID) ?>">Read More...</a>

If you want to add the link at the end of the content you could do:

return implode(' ', array_slice($words, 0, $word_limit)) . '<a href="'.get_permalink($post->ID).'">Read More...</a>';
share|improve this answer
    
Ha awesome. I added this just after I posted. Thanks :) –  user1676224 Mar 1 '13 at 15:48
    
If this answered your question, could you hit the check mark at the left side the answer? –  Mike Madern Mar 4 '13 at 7:48

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.