最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Echo short code syntax

programmeradmin4浏览0评论

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

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

Share Improve this question asked Jan 25, 2020 at 12:24 Faruk rızaFaruk rıza 982 silver badges11 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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) . "\"]"); ?>

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论