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

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
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


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.