• Hi,

    I am making a wordpress theme, my first ever, and in that i wanted to display featured posts thumbnails. The user has to enter post IDs in the dashboard settings and those IDs’ thumbnail and post title will be displayed.

    After thorough research, i came across 1 tutorial which fulfilled my aim with the help of a plugin. The code had to be entered into my functions.php file. Here’s the code:

    [code moderated as per forum rules - please use the pastebin]

    Now, to show this feature, i had to enter the following code wherever i want to display these featured thumbnails (homepage)

    <h3>Featured</h3>
    <?php featuredpostsList(); ?>

    Everything is fine and normal at this point. But, when my theme will be newly used,there will be no posts and hence user cannot enter post IDs to display the featured posts thumbnail. In that case, i don't want anything to show at all in that space. But how do i do it?

    At present, when post IDs are not entered in my dashboard settings, this is displayed:

    Featured (in h3)
    None Found (in bold)

    I don't want this to appear. This is done by this coding from the above code:

    <?php }
    } else {
    echo $before ."None found". $after;

    So how do i achieve my goal?

    I know i have to wrap...

    <h3>Featured</h3>
    <?php featuredpostsList(); ?>

    ...in an if-else statement. But what could be the exact coding? what variable/condition to use? I tried if(isset... and if(get_option... but nothing works. They remove the thumbnails even when post IDs r entered in dashboard settings.

    Please help me with the exact coding required in if-else (or any other solution if its there).

    Phew...!!!

    Thanks.

  • The topic ‘Help with If Else (variable)’ is closed to new replies.