Running custom queries is admin meta boxes
-
I’m building a custom meta box for inclusion on a custom post type page (‘press_releases’) which feeds in a list of recently posted items from a separate custom post type (‘videos’).
The idea is that the user can select which videos are displayed in the side panel of that particular press release.
I’ve added the meta box in standard way:
add_meta_box('post_info3', 'Select media', 'media_selection_box', 'press_releases', 'side', 'high');
In the added meta box I’m running a custom query to call a list of posts from the ‘video’ post type. It’s all working good except for 1 weird little problem.
When I run this query:
$args = array ( 'post_type' => 'video', 'artists_tax' => $artist_name ); $media_query = new WP_Query($args);
in the meta box, it beings back the correct posts from the video post type, but it also changes the title and body content of the main post to the title of the last entry brought back by the query.
It also changes the slug of the post from:
https://domain.com/press_release/post-title
to:
https://domain.com/video/post-title
Obviously this query is causing a bit of conflict somewhere. I’ve tried running wp_reset_query but to no avail.
Has anyone had this problem before? Any ideas how to get round it?
- The topic ‘Running custom queries is admin meta boxes’ is closed to new replies.