You need to specify a post type in your WP_Query
arguments when you need to query any other post type accept the build in post type post
.
By default, post_type
is set to post
, so when no specific post type is set manually by the user, WP_Query
will query posts from the post type post
Additionally, caller_get_posts
have been deprecated for a very very long time now. If you had debug turned on, you would have recieved a deprecation notice about this. The correct arguments to use is ignore_sticky_posts
.
I would also not use the $post
global as it is unreliable, for reliability, rather use $GLOBALS['wp_the_query']->get_queried_object()
. You can read up on this subject in my answer here
get_the_tags()
is also faster than wp_get_post_tags()
as the latter requires an extra db call.
One last note, wp_reset_query()
is used with query_posts
, the correct function to use with WP_Query
is wp_reset_postdata()
In essence, you can try the following
$post_id = $GLOBALS['wp_the_query']->get_queried_object_id();
$tags = get_the_tags( $post_id );
if ( $tags
&& !is_wp_error( $tags )
) {
$args = [
'post__not_in' => [$post_id],
'post_type' => 'doing',
'tag__in' => [$tags[0]->term_id],
// Rest of your args
];
$my_query = new WP_Query( $args );
// Your loop
wp_reset_postdata();
}