Title: How to change &#8220;Read More&#8221; PHP code
Last modified: August 18, 2016

---

# How to change “Read More” PHP code

 *  [slobizman](https://wordpress.org/support/users/slobizman/)
 * (@slobizman)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/how-to-change-read-more-php-code/)
 * The following code works in my index.php page:
 * `
    <?php if(is_category() || is_archive()) { the_excerpt(); } else { the_content('
   Read the rest of this entry &raquo;'); } ?>   But, when I add the line to “Read
   More…” to the excerpt display, I get a parse error.
 * `
    <?php if(is_category() || is_archive()) { the_excerpt(); <a href="<?php the_permalink()?
   >" title="full post">Read more...</a> ; } else { the_content('Read the rest of
   this entry &raquo;'); } ?>
 * I’ve tried all sorts of ways to do this and I can’t get it to work. Any ideas?(
   I’m not _obviously_ good at this.)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/how-to-change-read-more-php-code/#post-177085)
 * The “Read more” link in your excerpt portion is not part of the PHP. This should
   work:
 * `<?php if(is_category() || is_archive()) {
    the_excerpt(); ?> <p><a href="<?php
   the_permalink() ?>" title="full post">Read more...</a></p> <?php } else {  the_content('
   Read the rest of this entry &raquo;'); } ?>
 *  Thread Starter [slobizman](https://wordpress.org/support/users/slobizman/)
 * (@slobizman)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/how-to-change-read-more-php-code/#post-177097)
 * Thank you very much! It works great.
 * Now I’m trying to move the “Read more…” up to the same line as where the the 
   excerpt ends, instead of a paragraph break down below it. I took out the paragraph
   tags and it still didn’t do it. The excerpt tag itself must add the line spacing.
 * Please let me know if there is a way to do this–to be specific, I’d like the “
   read more…” to follow the last character of the excerpt.
 *  [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * (@kafkaesqui)
 * [21 years, 2 months ago](https://wordpress.org/support/topic/how-to-change-read-more-php-code/#post-177112)
 * That’s a trickier issue of sorts in WP because of the paragraph tags added to
   the excerpt’s content. A way around it might be to use `the_excerpt_rss()`, or
   perhaps even `the_content_rss()`, like so:
 * `<?php if(is_category() || is_archive()) { ?>
    <p><?php the_content_rss('', 1,'',
   50); ?> <a href="<?php the_permalink() ?>" title="full post">Read more...</a>
   </p> <?php } else { the_content('Read the rest of this entry &raquo;'); } ?>
 * (Note slight change in php tagging; the last parameter value in `the_content_rss()`(
   50) defines the amount of words to display before cutting the text.)
 * The limitation to this is that either of the _rss tags removes all html formatting
   for your “excerpt”, placing everything on one line.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to change “Read More” PHP code’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Kafkaesqui](https://wordpress.org/support/users/kafkaesqui/)
 * Last activity: [21 years, 2 months ago](https://wordpress.org/support/topic/how-to-change-read-more-php-code/#post-177112)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
