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.


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>';
| 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 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.