WordPress.org

Ready to get started?Download WordPress

Forums

Display preview WITH formatting? (7 posts)

  1. GokuMew2
    Member
    Posted 6 years ago #

    Hi again!

    I was wondering if there is any way to show x number of words in an entry WITH formatting before automatically cutting off the entry and displaying a "More..." link? I've read that you can do this with formatting stripped, but I want to retain all formatting. Is it possible?

    Also, what does <?php the_content_rss('More...', FALSE, '', 50); ?> output? I tried that in hopes that it would show a More... link after 50 words, but that didn't happen.

  2. Bodhipaksa
    Member
    Posted 6 years ago #

    Sounds like you want to try "the excerpt reloaded" plugin. It replaces the function the_excerpt and is much more customizable.

    RSS is completely unrelated. You can read about that function here.

  3. boober
    Member
    Posted 6 years ago #

    or you can do it without a plugin. Just use the_content instead of the_excerpt in your themes index.php and then use the 'more' tag in your posts.

  4. GokuMew2
    Member
    Posted 6 years ago #

    > Haecceity
    Thanks! I'm using it now. Do you know if there's any way to have the more link align to the right? Or, have the link appear right after where the entry is cut off (instead of going to the next line)?

    > boober
    But the point is I don't want to insert a more tag every time... I just wanted it done automatically.

  5. Bodhipaksa
    Member
    Posted 6 years ago #

    Interesting question:

    The code is something like this:

    <?php the_excerpt_reloaded(80, '<a><img><strong><em>', 'content', TRUE, 'Click to read more&nbsp;&raquo;', TRUE, 0, TRUE); ?>

    with the "Click to read..." text being what I've chosen as my "More" text. If you simply insert a line break at the start of the "more" parameter then it'll appear on a new line:

    <?php the_excerpt_reloaded(80, '<a><img><strong><em>', 'content', TRUE, '<br />Click to read more&nbsp;&raquo;', TRUE, 0, TRUE); ?>

    At least it did for me when I just tested it.

    In theory you could instead put a <p> around the "more" parameter and give it whatever class in your CSS aligns text to the right. So in my case it would be:

    <?php the_excerpt_reloaded(80, '<a><img><strong><em>', 'content', TRUE, '<p class="textright">Click to read more&nbsp;&raquo;</p>', TRUE, 0, TRUE); ?>

    But the problem with this is it leaves an ellipsis (...) on the preceding line. You could probably edit the plugin to get rid of that, as long as you back up and know what you're looking for.

  6. Bodhipaksa
    Member
    Posted 6 years ago #

    OK, line 129 in the plugin:

    $output .= ($showdots && $ellipsis) ? '...' : '';

    Edit out the three dots and you won't get the ellipsis on the previous line, like so:

    $output .= ($showdots && $ellipsis) ? '' : '';

    That plus inserting <p> tags around the "more" text will give you what you want, as long as the p has a class that aligns the text to the right.

  7. GokuMew2
    Member
    Posted 6 years ago #

    I don't mind the ellipsis. I fond out how to format the more link position. It said how in the plugin documentation. I added

    .more-link {
       font-weight: bold;
       text-align: right;
    }

    to my template's stylesheet and voila! The link is still in its own separate paragraph but oh well. It's no biggie. Thanks for the help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags