Using do_shortcode() with variables?
Posting here as unable to post in Advanced forum:
I’m using the “PHP Code for Posts and Pages” plugin at
http://www.AvengersCollectibles.com/wp to echo a shortcode (Amazon list from “Azon Pro Shopping List” in this case) if the in_category(Captain America) criteria is met and found 15 good product categories to offer.
Unfortunately, Amazon limits API calls to something like 2000/hr.
With that said, I’m trying to have the script randomly select one of 3
shortcodes (3 lists with 5 product categories each). I think I’m on the
right track but can not seem to get the code correct:
<?php if (in_category('Captain America')) echo do_shortcode('[asle id=11]'); ?>
Example of random selection:
<?php $input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank"); $rand_keys = array_rand($input, 2); echo $input[$rand_keys] . "\n"; echo $input[$rand_keys] . "\n"; ?>
but not quite sure how to combine the two. Any and all suggestions will be greatly appreciated.
- The topic ‘Using do_shortcode() with variables?’ is closed to new replies.