Per-post custom "(more...)" (11 posts)

  1. ringmaster
    Posted 11 years ago #

    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.

  2. nyee
    Posted 11 years ago #

    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?

  3. davidchait
    Posted 11 years ago #

    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.

  4. nyee
    Posted 11 years ago #

    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.

  5. ringmaster
    Posted 11 years ago #

    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 {}.

  6. nyee
    Posted 11 years ago #

    thanks :)

  7. iomej
    Posted 11 years ago #

    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

  8. NuclearMoose
    Posted 11 years ago #

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

  9. carthik
    Posted 11 years ago #

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


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

  10. Ozh
    Posted 11 years ago #

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

  11. iomej
    Posted 11 years ago #

    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)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.