the code is
<div class="huili-relevant-left">
<a href="<?php echo get_post_meta($post->ID,"taobao_value",true);?>" hidefocus="true" target="_blank" class="btn-buy js-log " data-log="page=p-huihui-discount-detail&type=buy">
<b>ï¿¥<?php echo get_post_meta($post->ID,"price_value",true);?></b>
<i>buy</i>
</a>
</div>
the has two Custom Fields is taobao_value
and price_value
now I want become a shortcode
Please help me
When you want to turn a snippet into a shortcode, you have to return a string. You cannot use
echo
or print anything in any other way.Also, always escape your data, and check if there are actually values.
I have used the HEREDOC syntax here, because it is easy to read:
You can insert the value into your posts now with
[taobao]
.