I want to make dynamic short code so insert php code of metabox text value to short code.

I wrote this:

<?php echo do_shortcode("[svg-flag flag=\"".get_post_meta($post->ID, 'ozellikler_text', true);".\"]"); ?>

Error :

Parse error: syntax error, unexpected ';', expecting ',' or ')' in /home/deniztas/themeforest-deneme2.deniz-tasarim.site/wp-content/themes/html5blank-stable/my_homepages/right.php on line 14

I explain what I want step by step:

There is a short code which shows country flags.

[svg-flag flag="tr"]

For example, this code shows Turkey (tr) flag.

I want to change the "tr"to dynamic metabox text value:

<?php  echo get_post_meta($post->ID, 'ozellikler_text', true) ?>

How can I do it? What is true syntax or simpler way than mine?

I ask this here instead of stackoverflow because I think maybe it needs wordpress info.Thanks

1 Answer 1


the error is saying to change ; to . - you will also want to remove the extra .:

<?php echo do_shortcode("[svg-flag flag=\""  . get_post_meta($post->ID, 'ozellikler_text', true) . "\"]"); ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.