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 :)
精彩评论