WordPress.org

Ready to get started?Download WordPress

Forums

How do I get the content of an entire post besides the last line? (5 posts)

  1. peterspliid
    Member
    Posted 1 year ago #

    I have the following code to get the content of a post

    <?php
    $my_postid = $post->ID;
    $content_post = get_post($my_postid);
    $content = $content_post->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
    ?>

    How do I leave out the last line in that post?

    Thanks!

  2. Andrew Bartel
    Member
    Posted 1 year ago #

    How do you expect to be able to output something to the page without using echo or print?

  3. peterspliid
    Member
    Posted 1 year ago #

    if you look at the code is says 'echo $content' at the bottom..

  4. Andrew Bartel
    Member
    Posted 1 year ago #

    Oh, all right. Last line of the post you're echoing.

    Does it have anything in common? You could find the last occurance of a <p> tag or specific css class or something and then hide it with jQuery, or we could work out a strictly php solution if you want.

  5. peterspliid
    Member
    Posted 1 year ago #

    The last line in all the pages contain a [gallery] tag. Usually it's just [gallery], it can have parameters such as [gallery orderby="rand"]. All those galleries have the css ID gallery-1 in common.

    I have no experience with jQuery and only little php knowledge, so I'd appreciate if could help me out.

    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.