get second ID from array

Your function is called “replace_thumbnail” so I am assuming you are trying to set/replace the post thumbnail (featured image): function replace_thumbnail($id) { $image_ids = array(); $media = get_attached_media( ‘image’, $id );; foreach($media as $item) { $image_ids[] = $item->ID; } // insert your featured image if (!empty($image_ids[1])) { update_post_meta( $id, ‘_thumbnail_id’, $image_ids[1] ); } // $image_ids_str … Read more

Complex Taxonomy scheme

Set your system up like this: locations – CPT administrative – hierarchical taxonomy natural – hierarchical taxonomy type – non-hierarchical taxonomy In the administrative taxonomy, you would create your tree: countries on the first level, regions second, departments and so on. Then, you would assign your locations to the smallest administrative denominations among your taxonomies … Read more

WP Query Conditionally query meta and taxonomy

If it’s not too much of work, you could switch from using meta data to custom (private) terms for tagging the tickets to agents. So when ever an agent (user) is created, you would have custom function run that executes wp_insert_term to create an agent-term, where the newly created user ID is used as the … Read more

WP Query – Show custom posts only if user contain some user meta

You could approach in two steps. First get all the users that match your criteria $user_ids = get_users([ ‘meta_key’ => ‘activeacc’, ‘meta_value’ => true, // or whatever value you are storing ‘fields’ => ‘ID’, ]); and then run your WP_Query for only those users $properties = new WP_Query([ ‘post_type’ => ‘property’, ‘author__in’ => $user_ids, ]); … Read more