0

I am using a widget to show some related posts.

I am inserting the code directly into the template as follows

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

However, I want to dynamically fill the 'post_include' field with an userID that I echo in as follows <?php echo get_user_meta($userID,'member_owner',true); ?>

So the code I am thinking would look something like this

<?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);
?>

I don't know how to add this dynamic ID to the array as what i am doing does not work.

looking for some guidance

4 Answers 4

1
"post_include" => get_user_meta($userID, 'member_owner', true),
Sign up to request clarification or add additional context in comments.

Comments

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);
?>

Comments

0

You cannot nest php opening tags.

Do it without reopening the php tags and use your function directly:

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

Comments

0

And if you need to set it afterwards you can simply do:

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.