0

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

2
  • 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, 2011 at 23:44
  • Pretty interesting. Is it a bug in twenty eleven theme or what
    – Dr Deo
    Nov 9, 2011 at 2:31

2 Answers 2

1

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.

2
  • 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, 2011 at 23:39
  • I am going tobe forced to add it manually .....echo '<a href="';the_permalink();echo '">More...</a>';
    – Dr Deo
    Nov 8, 2011 at 23:49
1

The actual documentation for this is here: http://codex.wordpress.org/Customizing_the_Read_More

Read the following section: http://codex.wordpress.org/Customizing_the_Read_More#Read_More_Techniques

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.