i have been working on a shortcode and I am having trouble passing $atts to it.
i can't figure out what i am doing wrong.
To say it another way, i cannot update 'input_product_image_ID' to a different value from it's default value of 13 by inserting a new value into the shortcode.
for example this shortcode would still return 13, not 12:
[product_picture input_product_image_ID="12"]
My code:
function article_image_insert_shortcode($atts) {
extract(shortcode_atts(array(
'input_product_image_ID' => 13,
), $atts));
$product_id = $input_product_image_ID;
// get product page url which is stored as caption
$product_page_url = get_post_field('post_excerpt', $product_id );
// get and insert image
$product_image = wp_get_attachment_image( $product_id , full_size );
// get image alt text which serves as the image title
$product_description_alt = get_post_meta($product_id , '_wp_attachment_image_alt', true);
// get image caption where link is stored
$thumb_img = get_post( get_post($product_id) );
// assign caption
$product_aff_url = $thumb_img->post_content;
$article_image_insert_shortcode = /* do some stuff */;
return $article_image_insert_shortcode;
}
add_shortcode('product_picture', 'article_image_insert_shortcode');
input_product_image_ID
to13
in shortcode function itself.function random_picture($atts) { extract(shortcode_atts(array( 'width' => 400, 'height' => 200, ), $atts)); return '<img src="http://lorempixel.com/'. $width . '/'. $height . '" />'; } add_shortcode('picture', 'random_picture');
input_product_image_id
instead ofinput_product_image_ID