WordPress.org

Ready to get started?Download WordPress

Forums

Is it possible to get only the content after ? (3 posts)

  1. VFHwebdev
    Member
    Posted 3 years ago #

    Is it possible to get just the portion of a post that comes after the more tag?

    I see all kinds of examples of how to get the content before the more tag or the entire post, but that's not what I need. I want to display the content before the more tag, then put some (or all) of the content after the more tag in a netflix style tool tip.

    I use jQuery to handle the display side of the tooltip, but I can't figure out how to return just the content after the more tag in a post.

    Can this be done?

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    general reading:

    http://codex.wordpress.org/Customizing_the_Read_More

    http://codex.wordpress.org/Template_Tags/the_content

    if you are in the loop, you could also try and use something like the following snippet to separate before/after more-tag:

    <?php
    $after_more = explode('<!--more-->', $post->post_content); if( $after_more[1] ) { echo $after_more[1]; } else { echo $after_more[0]; }
    ?>
  3. VFHwebdev
    Member
    Posted 3 years ago #

    That worked perfectly! I thought about trying something like that, but when I viewed my code on my WP generated pages, the <!--more--> tag didn't show up in the content so I figured it wasn't being returned in the post_content. I guess it is! Sweet!

    Many thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags