WordPress.org

Ready to get started?Download WordPress

Forums

Condition not working (6 posts)

  1. battle91
    Member
    Posted 1 year ago #

    <?php if (get_option('dailynotes_thumbnails') == 'on' && $thumb <> '') : ?>
    
    <?php print_thumbnail($arr[$j]["thumb"], $arr[$j]["use_timthumb"], $arr[$j]['title'] , 149, 125, '', $post = $arr[$j]["post"]); ?>
    
    <?php else : ?>
    
    <h2><?php echo($arr[$j]['title']); ?></h2>
    
    <?php endif; ?>

    It is out putting the thumbnail no matter what.. i need it to only show the title is there is no thumbnail.. any help ?

  2. converting2wp
    Member
    Posted 1 year ago #

    Are you sure $thumb is set? Are you sure it is a string (so comparison to '' makes sense)? Would something like

    !empty($thumb)
    instead of
    $thumb <> ''

    work better?

  3. battle91
    Member
    Posted 1 year ago #

    hi you are right, so thumb was not set - I revisted the code and have this now:

    but still not working properly :/

    <?php
    $thumb = get_post_meta($post->ID, 'thumb', true);
    if ($thumb == '')
    { ?>
    
    <?php print_thumbnail($arr[$j]["thumb"], $arr[$j]["use_timthumb"], $arr[$j]['title'] , 149, 125, '', $post = $arr[$j]["post"]); ?>
    <h2><?php echo($arr[$j]['title']); ?></h2>
    
    <?php } else { ?>
    <h2 class="larger-font"><?php echo($arr[$j]['title']); ?></h2>
    <?php } ?>

    Any further help or suggestion would be very appreciated, thank you!

  4. converting2wp
    Member
    Posted 1 year ago #

    When trying to figure something like this out, I resort to debugging tools that confirm/deny what I think is true about the variables. Some links that may be helpful:

    http://nacin.com/2010/04/23/5-ways-to-debug-wordpress/
    http://fuelyourcoding.com/simple-debugging-with-wordpress/
    http://codex.wordpress.org/Editing_wp-config.php#Configure_Error_Log
    https://gist.github.com/3219824

    Best wishes.

  5. battle91
    Member
    Posted 1 year ago #

    I solved it !!!

    $thumb

    should have been

    $arr[$j]["thumb"]

    Thanks!!

  6. converting2wp
    Member
    Posted 1 year ago #

    Congrats! If you mark the topic as resolved, it'll save the volunteers here from checking to see if you need more help.

Topic Closed

This topic has been closed to new replies.

About this Topic