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.

on a site am writing, on the home page i want to achieve the following

  • Posts should appear as excerpts with links to full article
  • Editors should have the power to explicitly control excerpt length

I tried the following solution:

  • create template file called home.php
  • use the_excerpt() in the loop

The problem
'read more' link is missing if user specifies explicit 'more' <!--more--> when creating a post but strangely if explicit 'more' is not specified in post, the link to full article is available. What the hell is going on? enter image description hereenter image description hereenter image description here

share|improve this question
1  
I was able to reproduce the effect in Twenty Eleven; possibly caused by the $more variable not being set, as I could fix it by adding global $more; $more = 1; before the loop in home.php. interestingly, the more-link keeps showing if the excerpt code is used in index.php. –  Michael Nov 8 '11 at 23:44
    
Pretty interesting. Is it a bug in twenty eleven theme or what –  Dr Deo Nov 9 '11 at 2:31
add comment

2 Answers

If you want to output the $post->post_content you need to use the_content() function, the_excerpt() function outputs $post->post_excerpt, so if the post doesn't have content on the excerpt field it doesn't output nothing.

A better solution should be a custom function that first checks for a user defined $post->post_excerpt and second for the $post->post_content and outputs the first defined.

share|improve this answer
    
The problem is not that it outputs nothing. Rather that there is no link to full article if an explicit `<!--more--> link is specified. I find this surprising –  Dr Deo Nov 8 '11 at 23:39
    
I am going tobe forced to add it manually .....echo '<a href="';the_permalink();echo '">More...</a>'; –  Dr Deo Nov 8 '11 at 23:49
add comment

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.