I have a custom theme that a third party developed for me and I’m trying to get to the bottom of a problem with shortcodes. I’m fairly new to Wordpress and PHP so please let me know if there is any other information I can supply.
I have custom text fields where I enter product prices. I am using the Custom Content By Country plugin so that I can display region-specific prices in these fields. This plugin uses a shortcode to specify what prices should be displayed for each country. For example:
[CBC country="gb" show="y"]£10[/CBC][CBC country=“us” show=“y”]$15[/CBC]
I worked out how to use the do_shortcode
function in my template to actually get the shortcode to work, like this:
<?php echo do_shortcode( get_post_meta($post->ID, 'fl_prodbuy1price', true) );?>
This works fine the first time I publish the post. My problem is that, once I click Publish/Update in the Wordpress UI, Wordpress truncates the displayed contents of the field - always at the first equals (=) sign:
[CBC country=
So if I go back and edit the post and update it, unless I remember to re-enter the full shortcode it publishes the post with a value of [CBC country= for the price.
Does this problem ring any bells for anyone? I’d appreciate any suggestions on where I should focus investigation.
esc_attr()