Reputation: 179
I've run into a little bit of a snag with shortcodes. I want it to take the variable and put it in place for the text that should usually go there, but instead of working it just doesn't load it up, even though I've tested it with the echo to see if it's putting anything out and it is.
<?php
$artistslug = the_field('artist_cat_slug');
echo $artistslug; // Here for test reasons
echo do_shortcode('[product_category category="'.$artistslug.'"]');
?>
Any help would be greatly appreciated.
Upvotes: 1
Views: 414
Reputation: 76666
Most probably, the_field()
displays the value. The plugin you are using might have a corresponding function to return the value instead, for e.g. get_the_field()
. Use that instead.
Edit after clarification in comments
From the documentation for the_field()
(emphasis mine):
Displays the value of the specified field. (this is the same as
echo get_field($field_name)
)
Exactly. Use get_field()
instead.
Upvotes: 2