开发者

How can i echo a variable inside of this?

Hello how can I add an echo开发者_如何学Python $name inside of this line ?

<?php echo do_shortcode('[latestbyauthor author="HERE" show="3"]'); ?>


I think your referring to concatenation, and you usually join a variable to a string with single dots (.).

usually like

"string 1" . $variable . "string 2";

your code would look like:

echo do_shortcode('[latestbyauthor author="' . $name . '" show="3"]');


I guess this is what you meant? http://codex.wordpress.org/Function_Reference/do_shortcode

if so, you can add $name with "." like this:

<?php echo do_shortcode('[latestbyauthor author="HERE" show="3"]').$name; ?>

But I guess you meant something else.


Just two other solutions

echo do_shortcode("[latestbyauthor author=\"$name\" show=\"3\"]");
echo do_shortcode(sprintf('[latestbyauthor author="%s" show="3"]', $name));

sprintf() is a nice function anyway :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜