Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Conditional Tags WordPress

  • SOLVED

Always seem to be confused with conditional tags!

<strong>Task;</strong>

Implementing an ecommerce solution called Shopp, the plugin utilizes custom templates, but there included within page.php inserted within the_content.

I would like some conditional statements to control some layouts between the Shopp catalog, Shopp cart/checkout and WP Pages.

<strong>Current code (within page.php)</strong>

<?php if ( shopp('catalog','is-category') ) {?>

SHOW SHOPP PRODUCTS

<?php } else { ?>

SHOW PAGE CONTENT

<?php } ?>


This obviously works, however I would like to include another conditional statement to control the cart view.

I tried <strong>if ( shopp('catalog','is-cart')</strong> to control the ‘cart’ but somehow this didn’t work.

Thinking less convoluted, ‘cart’ is also an actual page, maybe we could create a basic if <strong>( is_page( '2' )</strong> above the Shopp conditional tag.

<strong>Broken Code</strong>

<?php if (( is_page( 'cart' )){?>

SHOW SHOPP CART PAGE

<?php if ( shopp('catalog','is-category') ) {?>

SHOW SHOPP PRODUCTS

<?php } else { ?>

SHOW PAGE CONTENT

<?php } ?>

Answers (3)

2011-04-06

Baki Goxhaj answers:

add ()( on line 5675


West Coast Design Co. comments:

OMG Amazing!

2011-04-06

AdamGold answers:

<?php
$page = get_page_by_title('Cart');
if ( shopp('catalog','is-category') ) {?>

SHOW SHOPP PRODUCTS

<?php } else if( is_page($page->ID) ) {
?>
SHOW CART CONTENT
<?php
} else { ?>

SHOW PAGE CONTENT

<?php } ?>

2011-04-06

yves vu answers:

Hi,
Please check slug of "Cart" page? (ex: domain.com/cart => cart is a slug)
So you can use this code:
<?php
if (is_page('cart')) {?>

SHOW SHOPP CART PAGE

<?php } else if(shopp('catalog','is-category')) { ?>

SHOW SHOPP PRODUCTS

<?php
} else { ?>

SHOW PAGE CONTENT

<?php } ?>