• Hello All! ??

    I’m new WordPress user. I’m trying to customize my BLOG page. What I would like to do, is to have some “photo inside” sign next to the topic of the post, in the main page loop, when the post contain images.

    I’d like to do it by checking the content of post, looking for “<img” phrase. When phrase is found I would display some photo camera image next to the topic, indicating that post contains images.

    My problem is that the_content() tag returns only excerpt and in my case excerpts usually comes without images.

    I will be greatful for any help! ??

    Greetings,
    Michal.

Viewing 3 replies - 1 through 3 (of 3 total)
  • My problem is that the_content() tag returns only excerpt
    That doesn’t really make sense. This tags returns/displays the whole content as opposed to the_excerpt tag.

    Michal,

    Your best bet is to scan the internal $post->post_content for the <img substring, and then display an image based on that. I’m assuming that you know a bit about php.

    <?php
    if(stristr($post->post_content, '<img')) { ?>

    <!-- Photo Inside Code -->
    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/camera-icon.gif" alt="Photo Inside" title="Photo Inside" />

    <?php } ?>

    Your problem isn’t that the_content() tag returns an excerpt; it’s that the_content() echoes the post content data to the screen as opposed to keeping it within system-level PHP for processing with a function like strstr or stristr.

    Thread Starter taszyn

    (@taszyn)

    Eston,

    thanks a lot! Your post solved my problem in one great moment :).

    Michal.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘“Photo inside” sign next to topic.’ is closed to new replies.