I need to print the user's id into this array but it doesn't seem to be working. I have tried all sorts of things from $user->ID to $user_id to no avail. I am trying to get the value from my functions.php Any help would be greatly appreciated!
Here what's in my php function:
$user_page = get_queried_object();
$user_id = $user_page->data->ID;
$args = array(
'post_type' => 'listings',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'stm_car_user',
'value' => $user_id
)
)
);
$query = new WP_Query($args);
I'm sorry if my question is a little vague, here is what I am trying to achieve I don't want to get the id of the currently logged in user, I want to get the id of the user that the information is on, I am displaying the user's posts on their profiles and I need their id's displayed dynamically for each profile, you get me? I hope this clarifies things...
meta_query
is terribly slow/expensive, you should be better off using a taxonomy namedstm_car_user
where the term names are user IDs, it would be significantly faster