expatgirl on "[Plugin: Amazon Product in a Post Plugin] Randomize on Refresh via PHP Sidebar Widget?"

ساخت وبلاگ

I'm trying to throw together a randomize-on-refresh sidebar widget of Amazon Product in a Post. I've already created a static PHP widget of AmPP, which shows one item (which is all I wish to show at any given time).

I've found a PHP function that works within a PHP-enabled text widget for producing randomization of strings, which - again - I have limited to one displayed result.

<?php
$input = array
("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 1);
echo $input[$rand_keys] . "n";
?>

PHP is not my strong point, so here's the question...

How can I successfully pass the AmPP shortcode into the array - or vice versa - so that it displays one randomized AmPP post at a time?

My first thought is setting up the full "amazonproducts ASIN=****" shortcodes into the array. (Although, for the life of me, I can't figure out the syntax for making that display correctly, given the brackets around the shortcode.)

My second thought is setting up an array within the shortcode itself, with the individual ASINs passed in as randomized array values, and using echo do_shortcode to display the output. (Part of me thinks this would be cleaner than the first option.)

My third thought is... ask for help.

In conjunction with all that (and potentially nullifying my second thought), I found this: Don’t do_shortcode().

Ideas? Guidance? Cribbable code with explanation of why it works?

Anybody? Bueller? Bueller? Bueller...

https://wordpress.org/plugins/amazon-product-in-a-post-plugin/

- - , .
.

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 248 تاريخ : يکشنبه 27 تير 1395 ساعت: 1:04