This is your code converted so it does not use global variables, and thus can’t stomp on anything. If this does not work, check your plugins: maybe one of them uses a hook in WP_Query
to change the query on the home page? get_posts()
gets around that by setting suppress_filters
to true
, but I don’t know whether that disables all hooks.
$args = array(
'meta_key'=>'_simple_fields_fieldGroupID_1_fieldID_8_numInSet_0',
'post_type' => 'stores',
'post_status' => 'publish',
'posts_per_page' => 10,
'caller_get_posts'=> 1
);
$sidebar_posts = get_posts( $args );
if ( $sidebar_posts ) {
// Do you want this for each post, or just once for the list?
echo '<ul>';
foreach ( $sidebar_posts as $s_post ) {
echo '<li>';
$post_link = '<a href="' . get_permalink( $s_post->ID ) . '" rel="bookmark" title="Permanent link to ' . esc_attr( get_the_title( $s_post->ID ) . '">';
$selected_value = get_post_meta( $s_post->ID, '_simple_fields_fieldGroupID_1_fieldID_9_numInSet_0', true );
echo $post_link . $selected_value . '</a> at ';
echo $post_link . get_the_title( $s_post->ID ) . '</a>';
echo '</li>';
}
echo '</ul>';
}