I would like to create a custom query where the post ID is equal to a value which is stored in a variable. If I do a var_dump of the variable I can see the ID that I want to use.
However I don't know how I can target that specific ID and use it in my query. I'm really new to this more advanced PHP work and I'm probably searching with the wrong search terms to get the answer.
This is a part of the var_dump of the $account where the ID is 164.
object(WP_Post)#4451 (24) { ["ID"]=> int(164)
This ID should be used within the query to target the specific post ID like:
$args = array(
'post_type' => 'account',
'p' => $account->ID,
);
Can this be done? And if so, how can alter the query to do this?
Edit: Updated the query above with the correct code. Also updated the right variable name in the original question.
Thanks in advance.
164?$account_id" is a very strange name for a var containing a post object... I doubt you mean what you posted in your question... Furthermore, "$account_id" seems to be or to contain the post you want to query... So do you really need this query?$account. I need the query afaik because the ID stored in the variable is a value of a custom user meta field.var_dump( $account )output, it's containing aWP_Postobject with a property$ID = 164... So it can only be the post you are already looking for... In this case, if you have already the post, you don't need to query it...^^"