• Hi there,
    I have the following 2 statments working, but I want to make it so that it can use either (a gallery, or a featured image) and I have no idea how to do that..

    I would like it to work as follows;

    If a value for “galleryID” exists, then display:

    <?php $galleryID="galleryID"; echo do_shortcode('[jj-ngg-jquery-cycle gallery="'.get_post_meta($post->ID, $galleryID, true).'" width="220" height="150"]'); ?>

    else, if a ‘Featured Image’ exists, display;

    <a href="<?php $PageURL="PageURL"; echo get_post_meta($post->ID, $PageURL, true); ?>" title="<?php the_title(); ?>">
    				<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'home-feature', array( 'title' => '', 'alt' => '' ) ); }
    else {
    	echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/no-img.gif" width="220" height="150" alt="' . the_title() .'" />';
    	}?>  </a>

    can anyone please help me achieve this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Something like

    if ($galleryID > 0) {
        // Show gallery
    }
    else {
        // Show featured image
    }

    That should be all that you need to do for that.

    Thread Starter ignitionmedia

    (@ignitionmedia)

    Sorry, unfortunately I’m pretty clueless with this,

    that gives me the following (which breaks the site);

    <?php
    					 if ($galleryID > 0) {
          <?php $galleryID="galleryID"; echo do_shortcode('[jj-ngg-jquery-cycle html_id="gallery'.get_post_meta($post->ID, $galleryID, true).'" gallery="'.get_post_meta($post->ID, $galleryID, true).'"  width="220" height="150"]'); ?>
    }
    else {
       	<?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'home-feature', array( 'title' => '', 'alt' => '' ) ); }
    else {
    	echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/no-img.gif" width="220" height="150" alt="' . the_title() .'" />';
    				}?>
    }?>

    any anyone help further?

    If you’re going to get into doing stuff like this, you sould take a bit more time to learn PHP. You’ll find in invaluable when you come to these sort of questions.

    <?php
    if ($galleryID > 0) {
        echo do_shortcode('[jj-ngg-jquery-cycle html_id="gallery'.get_post_meta($post->ID, $galleryID, true).'" gallery="'.get_post_meta($post->ID, $galleryID, true).'"  width="220" height="150"]');
    }
    else {
        if ( has_post_thumbnail() ) {
            the_post_thumbnail( 'home-feature', array( 'title' => '', 'alt' => '' ) );
        }
        else {
            echo '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/no-img.gif" width="220" height="150" alt="' . the_title() .'" />';
        }
    }
    ?>

    That’s just the markup fixed up, I don’t know if that works or not, but the actual code won’t break anything now.

    Thread Starter ignitionmedia

    (@ignitionmedia)

    oh great, almost works, its just not showing the gallery, rather reverting to the no-img.gif when in fact there is a gallery, but i will give it a crack and see why its not working

    thanks heaps for your help

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Help with If/eEsle statement please?’ is closed to new replies.