Support » Fixing WordPress » Per-post custom “(more…)”

  • You can easily customize the text used for [more] in your posts using the new custom field feature in WP. Find the line in your index.php that says:
    <?php the_content(); ?>
    And replace it with this:

    $somemore = '(more...)';
    $maybemore = get_post_custom_values('more');
    if(count($maybemore) > 0) $somemore = $maybemore[0];
    the_content('<span class="more">'.$somemore.'</span>');

    With that code in place, when you add a custom field called “more” to any post, it will use that text instead of the default. The default is the “(more…)” in the code above.

Viewing 10 replies - 1 through 10 (of 10 total)
  • But is there a way to target the “more” part of a post directly in index.php?
    I just ported from MT, and I used the “extended entry” (MT equivalent of “more”) for information relating to each post but which I could format differently. Is there a way I can do that in WP without using cutom fields given that all my entries are already using “more” for that information?

    I don’t understand the question… You mean when you go into the single-post page, you want to be able to apply different CSS styling to it? Or even in that case, you want the pre-more section one style, and the post-more text in a different style?
    Both are doable, though the former is simple tweaks to index.php, while the latter might need a plugin as it’s a more major change.

    I want to do what davidchatt said:
    How do I apply one style to pre-more and another style to post-more?
    I don’t mean during “writing” a post (which I think ringmaster is referring to). I mean when it is “displayed” in index.php.

    Try this.
    Look for a line (near 126) in wp-includes/template-functions-post.php like this:
    $output .= ''.$content[1];
    Change it to this:
    $output .= '<div id="themore">'.$content[1].'</div>';
    You should be able to address your more content in CSS with #themore {}.

    thanks 🙂

    When I use ‘more ‘ in a post content and then click on this link, i see only the text after the teaser.
    I would like to see the whole page whit the header, the title…
    What have I to change in wp-includes/template-functions-post.php ? Which line and what Have I to write ?
    Thank you

    This seems to be more complex than necessary. I just edit the text in the appropriate php file.

    the function the_content takes three parameters, so in your index.php, use


    instead of the_content(), to not jump to after the tag.

    (i’d put class="themore" instead of id="themore" because you’ll have several themore’s in the same page)

    Thank you for your kind reply.
    I tried your solution, wrote
    the_content(‘More…’,’1′,’ ‘);
    I jump to the beginning of the post, not to the title… and not to the whole page (with the header)

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Per-post custom “(more…)”’ is closed to new replies.