2012-10-04 229 views
0

我正在使用小部件來顯示一些相關的帖子。將動態元素添加到陣列

我直接插入代碼到模板如下

<?php 
$args = array(
"post_author_url" => "no", 
"post_include" => "3456", 
"layout_mode" => "multi_column","layout_num_cols" => "3"); 
special_recent_posts($args); 
?> 

不過,我要動態地填補了「post_include」字段與我呼應如下<?php echo get_user_meta($userID,'member_owner',true); ?>

所以一個用戶ID代碼我想到會是這個樣子

<?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添加到陣列中的我在做什麼做沒有工作。

尋找一些指導

回答

1
"post_include" => get_user_meta($userID, 'member_owner', true), 
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); 
?> 
0

不能嵌套的PHP開始標籤。

直接做沒有重啓php的標籤和使用功能:

"post_include" => get_user_meta($userID,'member_owner',true);

0

如果你需要事後進行設置,你可以簡單地做:

$args['post_include'] = get_user_meta($userID, 'member_owner', true);