Craig
Forum Replies Created
-
No worries. Thank you Michael.
Hi Michael
I also experienced the same issue as Frank but using a different theme/plugin. I have traced it to the use of the inc-preview.php file in the Facebook Thumb Fixer plugin. When that file is included in the meta_box_content() function it causes the problem where the URL changes.
I think what is happening is that the preview is rendering the page and in the case I found, executing a shortcode within the post content which did a WP_Query(). Even though the shortcode function called wp_reset_postdata() after the query, it appears that it messed up some global variables which the admin page uses.
In my case it changed the posts URL to that of the last post found in the post WP_Query() in the shortcode.
The fix I have at the moment is to comment out the inc-preview.php includes in the main plugin file and this makes the problem stop. I am not sure what the expected behaviour is if a shortcode expected to be executed in the frontend is executed in the backend.
I thought this info might help. The contents of the shortcode function which causes this is:
function director_display()
{
$args = array(
‘post_type’ => ‘director’,
‘post_status’ => ‘publish’,
‘orderby’ => ‘menu_order’,
‘order’ => ‘ASC’,
‘posts_per_page’ => -1,
);
$the_query = new WP_Query( $args );
// The Loop
while ( $the_query->have_posts() ) {
global $post;
$the_query->the_post();
$director_title = get_post_meta( $post->ID, ‘director_title’, true );
// Do stuff
}
// Reset back to the original query now we have done this loop in here
wp_reset_postdata();
}
add_shortcode(‘DIRECTOR_DISPLAY’,’director_display’);Regards