• Resolved mikelacroix

    (@mikelacroix)


    I need a little help!

    I’m fully aware that this might be the noobyish noob problem ever, but my PHP skills are very rudimentary.

    What I want to do is to set up a condition where the beginning of an entry would return one of three results:

    1) A video
    2) If no video is set, a thumbnail
    3) If no thumbnail is set, nothing

    The video is embedded via a plug in.

    Here’s what I have:

    <div class="entry">
    
    <?php if ( get_post_meta($post->ID, "_videoembed", true) || get_post_meta($post->ID, "_videoembed_manual", true) ): ?>
            <div class="video">
                <?php echo p75GetVideo($post->ID); ?>
            </div>
            <?php endif; ?>
    <?php
    if ( has_post_thumbnail() ) { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=200&w=490&zc=1" alt=""/></a>
    <?php } else { ?>
    	<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
    <?php } ?>
    <?php the_excerpt(); ?>
    <div class="clear"></div>
    </div>

    What am I doing wrong? I know it has something to do with if/else commands, but I’m lost as to what to do next.

    Many, many thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    Try this

    <div class="entry">
    
    <?php if ( get_post_meta($post->ID, "_videoembed", true) || get_post_meta($post->ID, "_videoembed_manual", true) ) { ?>
            <div class="video">
                <?php echo p75GetVideo($post->ID); ?>
            </div>
    <?php } else if ( has_post_thumbnail() ) { ?>
    			<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=200&w=490&zc=1" alt=""/></a>
    <?php } else { ?>
    			<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
    <?php } ?>
    
    <?php the_excerpt(); ?>
    
    <div class="clear"></div>
    </div>
    Thread Starter mikelacroix

    (@mikelacroix)

    It worked like a charm! So basically, <?php } else if ( has_post_thumbnail() ) { ?> was the way to go. But I thought I needed an <?php endif; ?> to hold it all together.

    I just learned something! Thanks so much, hiteshanjara!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help with php conditions.’ is closed to new replies.