我在localhost上开发了一个站点,并将所有内容转移到了实时站点。实时站点和临时站点之间的查询完全相同,但该查询在我的实时站点上不起作用。
我正在尝试从类别中查询随机帖子,以显示在我的页脚中。这是一个非常简单的查询,所以我不知道为什么它不起作用。它只是在每次重新加载页面时向我显示相同的帖子。
Localhost,它按预期工作,并显示来自该帖子类型的随机帖子。
<?php $recipesloop = new WP_Query( array( \'post_type\' => \'recipes\', \'posts_per_page\' => \'1\', \'orderby\' => \'rand\') ); ?>
返回的内容如下:
WP_Query Object (
[query_vars] => Array (
[post_type] => recipes
[posts_per_page] => 1
[orderby] => rand
[error] =>
[m] =>
[p] => 0
[post_parent] =>
[subpost] =>
[subpost_id] =>
[attachment] =>
[attachment_id] => 0
[name] =>
[static] =>
[pagename] =>
[page_id] => 0
[second] =>
[minute] =>
[hour] =>
[day] => 0
[monthnum] => 0
[year] => 0
[w] => 0
[category_name] =>
[tag] =>
[cat] =>
[tag_id] =>
[author] =>
[author_name] =>
[feed] =>
[tb] =>
[paged] => 0
[comments_popup] =>
[meta_key] =>
[meta_value] =>
[preview] =>
[s] =>
[sentence] =>
[fields] =>
[menu_order] =>
[category__in] => Array (
)
[category__not_in] => Array (
)
[category__and] => Array (
)
[post__in] => Array (
)
[post__not_in] => Array (
)
[tag__in] => Array (
)
[tag__not_in] => Array (
)
[tag__and] => Array (
)
[tag_slug__in] => Array (
)
[tag_slug__and] => Array (
)
[post_parent__in] => Array (
)
[post_parent__not_in] => Array (
)
[author__in] => Array (
)
[author__not_in] => Array (
)
[ignore_sticky_posts] =>
[suppress_filters] =>
[cache_results] =>
[update_post_term_cache] => 1
[update_post_meta_cache] => 1
[nopaging] =>
[comments_per_page] => 50
[no_found_rows] =>
[order] => DESC
)
[tax_query] => WP_Tax_Query Object (
[queries] => Array (
)
[relation] => AND
)
[meta_query] => WP_Meta_Query Object (
[queries] => Array (
)
[relation] =>
)
[date_query] =>
[post_count] => 1
[current_post] => -1
[in_the_loop] =>
[comment_count] => 0
[current_comment] => -1
[found_posts] => 10
[max_num_pages] => 10
[max_num_comment_pages] => 0
[is_single] =>
[is_preview] =>
[is_page] =>
[is_archive] => 1
[is_date] =>
[is_year] =>
[is_month] =>
[is_day] =>
[is_time] =>
[is_author] =>
[is_category] =>
[is_tag] =>
[is_tax] =>
[is_search] =>
[is_feed] =>
[is_comment_feed] =>
[is_trackback] =>
[is_home] =>
[is_404] =>
[is_comments_popup] =>
[is_paged] =>
[is_admin] =>
[is_attachment] =>
[is_singular] =>
[is_robots] =>
[is_posts_page] =>
[is_post_type_archive] => 1
[query_vars_hash] => 79b1d4c4dd907be2bdf06d3b2e4bd2f8
[query_vars_changed] =>
[thumbnails_cached] =>
[stopwords:WP_Query:private] =>
[query] => Array (
[post_type] => recipes
[posts_per_page] => 1
[orderby] => rand
)
[request] => SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = \\\'recipes\\\' AND (
wp_posts.post_status = \\\'publish\\\' OR wp_posts.post_status = \\\'private\\\'
) ORDER BY RAND(
) DESC LIMIT 0, 1
[posts] => Array (
[0] => WP_Post Object (
[ID] => 228
[post_author] => 2
[post_date] => 2014-03-04 11:00:59
[post_date_gmt] => 2014-03-04 16:00:59
[post_content] => Combine flour, salt, pepper and cayenne in a saucepan; gradually add chicken broth and skim milk, stirring with a wire whisk until smooth. Place over medium heat and cook, stirring constantly, until thickened. Add mustard and lemon juice. Allow to cool. Heat margarine and oil in a skillet. Add chicken pieces, green onions and garlic. Sauté until chicken is just firm and cooked through, about 10 minutes. Prepare pasta according to package directions and drain. Combine sauce, chicken and pasta mixture. Put into a 2 ½-quart casserole dish. Sprinkle top with almonds, chopped chives and paprika (
if using
). Bake at 375° for 10 minutes or until heated through.
[post_title] => Zingy Lemon Chicken Pasta
[post_excerpt] => Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => zingy-lemon-chicken-pasta
[to_ping] =>
[pinged] =>
[post_modified] => 2014-03-07 15:07:38
[post_modified_gmt] => 2014-03-07 20:07:38
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://baltimarket.wpengine.com/?post_type=recipes&p=228
[menu_order] => 0
[post_type] => recipes
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
)
[post] => WP_Post Object (
[ID] => 228
[post_author] => 2
[post_date] => 2014-03-04 11:00:59
[post_date_gmt] => 2014-03-04 16:00:59
[post_content] => Combine flour, salt, pepper and cayenne in a saucepan; gradually add chicken broth and skim milk, stirring with a wire whisk until smooth. Place over medium heat and cook, stirring constantly, until thickened. Add mustard and lemon juice. Allow to cool. Heat margarine and oil in a skillet. Add chicken pieces, green onions and garlic. Sauté until chicken is just firm and cooked through, about 10 minutes. Prepare pasta according to package directions and drain. Combine sauce, chicken and pasta mixture. Put into a 2 ½-quart casserole dish. Sprinkle top with almonds, chopped chives and paprika (
if using
). Bake at 375° for 10 minutes or until heated through.
[post_title] => Zingy Lemon Chicken Pasta
[post_excerpt] => Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => zingy-lemon-chicken-pasta
[to_ping] =>
[pinged] =>
[post_modified] => 2014-03-07 15:07:38
[post_modified_gmt] => 2014-03-07 20:07:38
[post_content_filtered] =>
[post_parent] => 0
[guid] => http://baltimarket.wpengine.com/?post_type=recipes&p=228
[menu_order] => 0
[post_type] => recipes
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
)