bubbafunk66 Posted February 10, 2015 Share Posted February 10, 2015 Hi, I'm using wordpress and woo commerce and i have a different banner slider on every product page and another on the main category page. I have tried using php to show the banner by id and by product title but it makes no difference, the error is still the same. On the main category page the main category banner shows along with the first product in that category, so two banners on the page. What am i doing wrong, surely by using an if statement that only works by ID, the banner should only work on this ID?Here is the code:- <?php if(is_product_category( 'powders' ) ) { echo do_shortcode('[smartslider2 slider=14]'); } ?> <?php if(get_the_ID()==78) { echo do_shortcode('[smartslider2 slider=11]'); } ?> <?php if(get_the_ID()==82) { echo do_shortcode('[smartslider2 slider=12]'); } ?> <?php if(get_the_ID()==85) { echo do_shortcode('[smartslider2 slider=13]'); } ?> Quote Link to comment Share on other sites More sharing options...
QuickOldCar Posted February 10, 2015 Share Posted February 10, 2015 (edited) I'll take a guess that both the statements are true when on that page. It's both product category powders and one of those id's You should probably use the conditional tags and can check for is_home(),is_page(),is_post(),is_single() and so on http://codex.wordpress.org/Conditional_Tags is_single() When a single post of any post type (except attachment and page post types) is being displayed. is_singular() Returns true for any is_single(), is_page(), or is_attachment(). untested... <?php //check if singular if(is_singular('post')){ //check for id's if(is_single('78')) { echo do_shortcode('[smartslider2 slider="11"]'); }elseif(is_single('82')) { echo do_shortcode('[smartslider2 slider="12"]'); }elseif(is_single('85')) { echo do_shortcode('[smartslider2 slider="13"]'); }else{ endif; } }else{ //if not singular check for product categories if(is_product_category('powders')) { echo do_shortcode('[smartslider2 slider="14"]'); } } ?> Edited February 10, 2015 by QuickOldCar Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.