• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP update_post_category_cache函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP update_post_information函数代码示例发布时间:2022-05-23
下一篇:
PHP update_post_caches函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap