Forums

Check if post was split (4 posts)

  1. newkind
    Member
    Posted 3 weeks ago #

    Hi,

    I was wondering if that's the only way to check if post has been split using <!--more--> tag to display image.

    <?php if(strpos($post->post_content, '<!--more-->')) { ?>
    <img src="http://google.com/image.jpg" alt="" />
    <?php } ?>

    ?? Maybe there's other way ?

  2. MichaelH
    moderator
    Posted 3 weeks ago #

    That seems reasonable. Are you looking for faster code or some other function that would do the same thing?

  3. newkind
    Member
    Posted 3 weeks ago #

    Well i was thinking about some other function as WordPress doesn't have included any conditional tag that would check if post was split :)

  4. MichaelH
    moderator
    Posted 3 weeks ago #

    No conditional that I know of...the function get_the_content uses this

    if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {

Reply

You must log in to post.

About this Topic