[resolved] Need help with if or elseif-statement (4 posts)

  1. ziirahdane
    Posted 4 years ago #

    Hey all,

    I am currently editing a theme (Volt) that uses the TimThumb script. I am trying to make the script 1) display an attached thumbnail if there is one 2) if not, display a thumbnail specific to that category, and 3) if no image is found for the category, display a default image.

    Here is part of the current script:

    if ( has_post_thumbnail()) {
    $img_src = wp_get_attachment_image_src( get_post_thumbnail_id($GLOBALS['post']->ID), '');
    $thumbnail = $img_src[0];
    else { $thumbnail = '';
    $default_thumb = $bloginfo.'/images/post_thumb.jpg';
    $thumbnail = ( $thumbnail == '' ) ? $default_thumb : $thumbnail;

    As you can see, 1) and 3) are taken care of in the default script. My issue is that I am a beginner in php and don't know how/where to put the 2) statement.

    Please help!

  2. ziirahdane
    Posted 4 years ago #

    Managed to get this working.

    My final solution:

    [Code moderated as per the Forum Rules. Please use the pastebin]

  3. Michael Moore
    Posted 4 years ago #

    Hey can I see your final code for this ziiradane. Im trying to accomplish something similar. Im trying to do something like, if post thumbnail, display it - else grab first image from post and display it - else display default image. Having a lot of trouble making this work and your code has been moderated here.

  4. ziirahdane
    Posted 4 years ago #

    Oh sure! Sorry!

    It's here: http://pastebin.com/Qq5iPHne

Topic Closed

This topic has been closed to new replies.

About this Topic