WP 3.3 & Magic Tags within PHP help

0

I read in another thread that magic tags can no longer be used in PHP and this killed my site.

If you could do me a favour show me how to convert these mixed tags into pure PHP that would help a lot.

Thank you!

<?php if (({@active}=="1" ) && ({@product_types.id}=="5" ) ): ?>

<?php echo do_shortcode('{@addtocart}'); ?>

asked Dec 17 '11 at 6:04

codebloo

7

add comment
enter at least 15 characters

3 Answers

1

Assuming you've defined your pods variable as $pods, you'll be able to replace these like this:

<?php
$active = $pods->get_field('active');
$prod_id = $pods->get_field('product_types.id);
if (($active == "1" ) && ($prod_id == "5")):  ?>
<?php echo do_shortcode($pods->get_field('addtocart') ); ?>

answered Dec 17 '11 at 7:57

chris.pilko

889

add comment
enter at least 15 characters
0

I tried that short code thing before and I didn't work but my syntax must have been off. Thank you very much! It works now! huzzah!

The active/prod types thing doesn't seem to make a difference. I thought perhaps it was the "check if active" php/magic tag because the homepage slider wasn't showing images until I updated that piece, but this still isn't working. Maybe the showimages helper doesn't work with the current update? I'll keep trying. THANK YOU!!!

answered Dec 18 '11 at 2:12

codebloo

7

add comment
enter at least 15 characters
0

Ok I fixed it. I had to pull out {@photo, showimages} and replace it with

<?php foreach ($this->get_field('photo') as $photo) { $img_thumb = wp_get_attachment_image_src($photo['ID'], 'thumbnail'); echo "<img src=\"{$img_thumb[0]}\" />"; }?>

answered Dec 18 '11 at 2:45

codebloo

7

edited Dec 18 '11 at 2:46

add comment
enter at least 15 characters