我一直在研究一个短代码,我在传递$ATT时遇到了问题。
我不知道我做错了什么。
换言之,我无法通过在短代码中插入新值将“input\\u product\\u image\\u ID”更新为与默认值13不同的值。
例如,此短代码仍将返回13,而不是12:
[product\\u picture input\\u product\\u image\\u ID=“12”]
我的代码:
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\');