WP_Query & Metabox, post slug problem
-
Hi everyone,
I’m writing a plugin using custom post type and metaboxes – who are called in post editing pages – and when I create a new post, or modify an old one, my post-slug automatically take the postname of the last custom post type I’ve called in my WP_Query.
I’ve tryed to remove part of my code for identifying what was going wrong and now, I know that is because of my WP_Query in a metabox on post editing pages (when I remove it, everything work fine).
I found a tread about that kind of bug on StackOverFlow.com, and someone say to use ‘get_posts();’ instead of ‘WP_Query’. So now I’m gonna try to change my code and see if everything work again.
My code is :
$albumQuery = new WP_Query( array( 'post_type' => 'album' ) ); while($albumQuery->have_posts() ) : $albumQuery -> the_post(); $idOfAlbum = get_the_ID(); $titleOfAlbum = get_the_title(); echo ' <li>'.$idOfAlbum.'|'.$titleOfAlbum.'</li> ' ; endwhile;
Any help on the conversion is welcome, but I’m creating this tread for helping people who can have that kind of misadventure on their own code.
I will post my new code when it will work again
- The topic ‘WP_Query & Metabox, post slug problem’ is closed to new replies.