I am working on this wordpress plugin and I am stuck in a request that will not reset. In the following function:
function WPSM_artists_autocomplete(){
$response = array();
query_posts('post_type=artist&posts_per_page=-1');
if (have_posts()) : while (have_posts()) : the_post();
$image_id = get_post_thumbnail_id();
$image_url = wp_get_attachment_image_src($image_id,'artist-icon');
$image_url = $image_url[0];
$response[] = array( get_the_ID() , get_the_title() , null, '<img src="'.$image_url.'" />'. get_the_title());
endwhile; endif;
wp_reset_query();
$output = json_encode($response);
$data = WPSM_CACHE_DIR."/data.json";
$fh = fopen($data, 'w') or die("can't open file");
fwrite($fh, $output);
fclose($fh);
echo WPSM_CACHE_URL."/data.json";
}
I use query_posts to populate the metabox. But wp_reset_query (); doesn't seem to be working properly. This affects all other exchange and related options. The global variable $ post is set by the most recent value of this request, and not by the default value of the message editing page.
I would love to hear how to solve this plugin. I can use everything to lead me in the right direction. Thanks in advance!
Greetings
Roni
source
share