我正在使用小部件来显示一些相关帖子。
我将代码直接插入模板中,如下所示
<?php
$args = array(
"post_author_url" => "no",
"post_include" => "3456",
"layout_mode" => "multi_column","layout_num_cols" => "3");
special_recent_posts($args);
?>
但是,我想动态填充'post_include'字段,其中包含我回复的用户ID,如下<?php echo get_user_meta($userID,'member_owner',true); ?>
所以我想的代码看起来像这样
<?php
$args = array(
"post_author_url" => "no",
"post_include" => "<?php echo get_user_meta($userID,'member_owner',true); ?>",
"layout_mode" => "multi_column","layout_num_cols" => "3");
special_recent_posts($args);
?>
我不知道如何将这个动态ID添加到数组中,因为我正在做的事情不起作用。
寻找一些指导
答案 0 :(得分:1)
"post_include" => get_user_meta($userID, 'member_owner', true),
答案 1 :(得分:1)
<?php
$args = array(
"post_author_url" => "no",
"post_include" => get_user_meta($userID,'member_owner',true),
"layout_mode" => "multi_column","layout_num_cols" => "3");
special_recent_posts($args);
?>
答案 2 :(得分:0)
你无法嵌套php开场标签。
不重新打开php标签并直接使用你的功能就可以了:
"post_include" => get_user_meta($userID,'member_owner',true);
答案 3 :(得分:0)
如果你之后需要设置它,你可以简单地做:
$args['post_include'] = get_user_meta($userID, 'member_owner', true);