龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > php编程 >

get_transient php Query posts and cache the query

时间:2014-06-22 15:10来源:网络整理 作者:网络 点击:
分享到:
php Query posts and cache the query [代码片段(21行)]
$bandeau_post = get_transient('top1_bandeau_post');

if (!is_array($bandeau_post) || count($bandeau_post)==0) {

    $args = array(
        'posts_per_page' => 5
        );
    $bandeau_post = array();
    $bandeau_post = query_posts($args);

    set_transient('top1_bandeau_post',$bandeau_post,60*60*$timeout);
}

foreach($bandeau_post as $post) :
        setup_postdata($post);

// the display code

endforeach;

精彩图集

赞助商链接