本文整理汇总了PHP中update_post_category_cache函数的典型用法代码示例。如果您正苦于以下问题:PHP update_post_category_cache函数的具体用法?PHP update_post_category_cache怎么用?PHP update_post_category_cache使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_post_category_cache函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_the_category
function get_the_category($id = false)
{
global $post, $category_cache;
if (!$id) {
$id = $post->ID;
}
if (!isset($category_cache[$id])) {
update_post_category_cache($id);
}
$categories = $category_cache[$id];
if (!empty($categories)) {
sort($categories);
} else {
$categories = array();
}
return $categories;
}
开发者ID:BackupTheBerlios,项目名称:steampress-svn,代码行数:17,代码来源:template-functions-category.php
示例2: get_the_category
function get_the_category($id = false) {
global $post, $category_cache;
if ( !$id )
$id = $post->ID;
if ( !isset($category_cache[$id]) )
update_post_category_cache($id);
$categories = $category_cache[$id];
if ( !empty($categories) )
sort($categories);
else
$categories = array();
return $categories;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:18,代码来源:template-functions-category.php
示例3: get_the_category
function get_the_category($id = false)
{
global $post, $category_cache, $blog_id;
$id = (int) $id;
if (!$id) {
$id = (int) $post->ID;
}
if (!isset($category_cache[$blog_id][$id])) {
update_post_category_cache($id);
}
$categories = $category_cache[$blog_id][$id];
if (!empty($categories)) {
usort($categories, '_get_the_category_usort');
} else {
$categories = array();
}
return $categories;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:18,代码来源:category-template.php
示例4: update_post_caches
function update_post_caches(&$posts) {
global $post_cache, $category_cache, $post_meta_cache;
global $wpdb, $blog_id;
// No point in doing all this work if we didn't match any posts.
if ( !$posts )
return;
// Get the categories for all the posts
for ($i = 0; $i < count($posts); $i++) {
$post_id_array[] = $posts[$i]->ID;
$post_cache[$blog_id][$posts[$i]->ID] = &$posts[$i];
}
$post_id_list = implode(',', $post_id_array);
update_post_category_cache($post_id_list);
update_postmeta_cache($post_id_list);
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:20,代码来源:functions.php
示例5: update_post_caches
function update_post_caches(&$posts) {
global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache;
global $wpdb;
// No point in doing all this work if we didn't match any posts.
if ( !$posts )
return;
// Get the categories for all the posts
for ($i = 0; $i < count($posts); $i++) {
$post_id_array[] = $posts[$i]->ID;
$post_cache[$posts[$i]->ID] = &$posts[$i];
$comment_count_cache[$posts[$i]->ID] = $posts[$i]->comment_count;
}
$post_id_list = implode(',', $post_id_array);
update_post_category_cache($post_id_list);
// Get post-meta info
if ( $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN($post_id_list) ORDER BY post_id, meta_key", ARRAY_A) ) {
// Change from flat structure to hierarchical:
$post_meta_cache = array();
foreach ($meta_list as $metarow) {
$mpid = (int) $metarow['post_id'];
$mkey = $metarow['meta_key'];
$mval = $metarow['meta_value'];
// Force subkeys to be array type:
if ( !isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid]) )
$post_meta_cache[$mpid] = array();
if ( !isset($post_meta_cache[$mpid]["$mkey"]) || !is_array($post_meta_cache[$mpid]["$mkey"]) )
$post_meta_cache[$mpid]["$mkey"] = array();
// Add a value to the current pid/key:
$post_meta_cache[$mpid][$mkey][] = $mval;
}
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:39,代码来源:functions.php
示例6: update_post_caches
function update_post_caches(&$posts)
{
global $post_cache, $category_cache, $comment_count_cache, $post_meta_cache;
global $wpdb;
// No point in doing all this work if we didn't match any posts.
if (!$posts) {
return;
}
// Get the categories for all the posts
for ($i = 0; $i < count($posts); $i++) {
$post_id_list[] = $posts[$i]->ID;
$post_cache[$posts[$i]->ID] =& $posts[$i];
}
$post_id_list = implode(',', $post_id_list);
update_post_category_cache($post_id_list);
// Do the same for comment numbers
$comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount\r\n\tFROM {$wpdb->posts}\r\n\tLEFT JOIN {$wpdb->comments} ON ( comment_post_ID = ID AND comment_approved = '1')\r\n\tWHERE ID IN ({$post_id_list})\r\n\tGROUP BY ID");
if ($comment_counts) {
foreach ($comment_counts as $comment_count) {
$comment_count_cache["{$comment_count->ID}"] = $comment_count->ccount;
}
}
// Get post-meta info
if ($meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM {$wpdb->postmeta} WHERE post_id IN({$post_id_list}) ORDER BY post_id, meta_key", ARRAY_A)) {
// Change from flat structure to hierarchical:
$post_meta_cache = array();
foreach ($meta_list as $metarow) {
$mpid = $metarow['post_id'];
$mkey = $metarow['meta_key'];
$mval = $metarow['meta_value'];
// Force subkeys to be array type:
if (!isset($post_meta_cache[$mpid]) || !is_array($post_meta_cache[$mpid])) {
$post_meta_cache[$mpid] = array();
}
if (!isset($post_meta_cache[$mpid]["{$mkey}"]) || !is_array($post_meta_cache[$mpid]["{$mkey}"])) {
$post_meta_cache[$mpid]["{$mkey}"] = array();
}
// Add a value to the current pid/key:
$post_meta_cache[$mpid][$mkey][] = $mval;
}
}
}
开发者ID:johnwonder,项目名称:WordPressLearn,代码行数:42,代码来源:functions.php
注:本文中的update_post_category_cache函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论