vendredi 24 juillet 2015

if statement not working, outputs else statement instead

I'm trying to output the if statement, but instead the else statement shows. I have created a page using Wordpress and assigned this template to the page. I'm trying to show product image and content if number of products is > 0, which it is. But instead it shows the else statement. Can someone please help?

<?php  
/*
Template Name: Product Single Template
*/
$productsPermalink = pods_var('last', 'url');
$singleProductPod = pods('products', $productsPermalink);
$numProducts = $singleProductPod->total();
?>

<?php get_header(); ?>

<section>
<?php  if($numProducts > 0): 
?>

    <h1><?php echo $singleProductPod->field('name'); ?></h1>

    <div class="instructor single">
        <img src="<?php echo $singleProductPod->field('image.guid') ?>" alt="<?php echo $singleProductPod->field('name')?>">
        <p><?php echo $singleProductPod->field('content')?></p>
    </div>


<?php  else: ?>
    <h3>There is no such product: <?php echo $productsPermalink; ?>, please select another product</h3>
<?php endif; ?>

Aucun commentaire:

Enregistrer un commentaire