How to change which pages display "read more" text (7 posts)

  1. nate451
    Posted 7 years ago #

    By default, it looks like the "read more" text in entries displays only on single post / permalink pages.

    I'd like to display the "more" text on the index page. (Why? So that I can hide it via javascript and have a link which then shows it.) Does anyone know how to make a specific page display the "more" text?

  2. rudolf45
    Posted 7 years ago #

    Actually, out of the box WP does not display the "read more" link on single post view, only on the multipost view pages like index, archives, search results.

  3. nate451
    Posted 7 years ago #

    Sorry, I'll try to clarify; I apologize for saying the wrong thing.

    I'd like to display the actual content that comes after the 'read more' link. WP seems fully capable of letting me do anything I want to the actual read more link. What I'd like to find out is how to make any given instance of the_content display all of the text and not just what comes before "read more".

    Does that make more sense?

  4. nate451
    Posted 7 years ago #

    In Movable Type, I would do this by using the <mt:EntryMore /> tag. That doesn't seem to be possible in WP, and I'm just trying to find a way to get this text on my index page.

  5. rudolf45
    Posted 7 years ago #

    I have never used MT, so I have no idea how that works. Maybe WP doesn't work in the way you expect it. It happens quite often when we switch from a script to another.

    In WP if you insert the "more" link while writing the post - it will cut the text on any multipost view.

  6. nate451
    Posted 7 years ago #

    Right. I'm attempting to modify that behavior.

    For the record, I made some headway, but it's editing post-template.php. I should probably figure out how to do this via a plugin.

    I modified lines 118-125 as follows:

    if ( count($content) > 1 ) {
    		if ( $more ) {
    			$output .= '<span id="more-'.$id.'"></span>'.$content[1];
    		} else {
    			$output = balanceTags($output);
    			if ( ! empty($more_link_text) )
    				$output .= '<p><a href="#" class="show">Read More &raquo;</a></p><div class="more"><span id="more-'.$id.'"></span>'.$content[1].'</div><!-- end .entrymore -->';

    Basically, the text in the "else" condition on line 121 seems to be what displays on a non-permalink page. I'd love anyone else's thoughts on more elegant ways to do this.

  7. nate451
    Posted 7 years ago #

    To be a bit clearer, the essential thing was adding .$content[1] to line 124. I don't know #$%@ about PHP, but it looks like the code sets the text before the <!--more--> link as the first item in the array ($content[0]) and the text after the <!--more--> link as the second item ($content[1]).

    I'd love a way to tell WP to append this data only on certain pages.

Topic Closed

This topic has been closed to new replies.

About this Topic