HTML 中的 PHP,即 wordpress 简码中的 PHP


PHP within HTML that is within a wordpress shortcode

好的,基本上我正在尝试包装;

<a class="userpro-init-chat" href="#" data-chat_with="<?php echo get_the_author_meta('ID'); ?> " data-chat_from="<?php echo get_current_user_id();?>" >Reply to this ad!</a>

在模板中的 WordPress 简码中。它应该很简单,对吧?

<?php echo  do_shortcode('[userpro_private]' <a class="userpro-init-chat" href="#" data-chat_with="<?php echo get_the_author_meta('ID'); ?> " data-chat_from="<?php echo get_current_user_id();?>" >Reply to this ad!</a> '[/userpro_private]'); ?>

但是,我不断收到错误"解析错误:语法错误,/home/content/67/11982267/html/tester/wp-content/themes/twentytwelve/content.php 中的意外T_CLASS在第 46 行"

谁能明白为什么会这样?

我在 php 相当新,所以我可能在其他人都很明显的地方做错了什么,但我真的很感激任何人的帮助!

非常感谢,詹姆斯

我希望这能解决问题。

$text = "<a class='userpro-init-chat' href='#' data-chat_with='". get_the_author_meta('ID')."' data-chat_from= '".get_current_user_id()."' >Reply to this ad!</a>";
echo  do_shortcode('[userpro_private]'.$text.'[/userpro_private]');