本文整理匯總了PHP中WP_query::reset_postdata方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_query::reset_postdata方法的具體用法?PHP WP_query::reset_postdata怎麽用?PHP WP_query::reset_postdata使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WP_query
的用法示例。
在下文中一共展示了WP_query::reset_postdata方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: search_everything_callback
function search_everything_callback()
{
$is_query = !empty($_GET['s']);
$result = array();
if ($is_query) {
$result = array('own' => array(), 'external' => array());
$params = array('s' => $_GET['s']);
$zemanta_response = se_api(array('method' => 'zemanta.suggest', 'return_images' => 0, 'return_rich_objects' => 0, 'return_articles' => 1, 'return_markup' => 0, 'return_rdf_links' => 0, 'return_keywords' => 0, 'careful_pc' => 1, 'interface' => 'wordpress-se', 'format' => 'json', 'emphasis' => $_GET['s'], 'text' => $_GET['text']));
if (!is_wp_error($zemanta_response) && $zemanta_response['response']['code'] == 200) {
$result['external'] = json_decode($zemanta_response['body'])->articles;
}
$SE = new SearchEverything(true);
if (!empty($_GET['exact'])) {
$params['exact'] = true;
}
$params["showposts"] = 5;
$post_query = new WP_query($params);
while ($post_query->have_posts()) {
$post_query->the_post();
$result['own'][] = get_post();
}
$post_query->reset_postdata();
}
print json_encode($result);
die;
}