編程語言 php java

WordPress無插件調用最新、熱門、隨機文章實例代碼

php HTML我幫您 1年前  4635次瀏覽
調用最新文章:

代碼如下:

    while ($post_query->have_posts()) : $post_query->the_post();
    $do_not_duplicate = $post->ID; ?>
  • ”>




調用熱門文章:

代碼如下:

    $post_num = 10; // 設置調用條數
    $args = array(
    ‘post_password’ => ”,
    ‘post_status’ => ‘publish’, // 只選公開的文章.
    ‘post__not_in’ => array($post->ID),//排除當前文章
    ‘caller_get_posts’ => 1, // 排除置頂文章.
    ‘orderby’ => ‘comment_count’, // 依評論數排序.
    ‘posts_per_page’ => $post_num
    );
    $query_posts = new WP_Query();
    $query_posts->query($args);
    while( $query_posts->have_posts() ) { $query_posts->the_post(); ?>
  • ” title=””>




調用隨機文章:

代碼如下:

    global $post;
    $postid = $post->ID;
    $args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 10);
    $query_posts = new WP_Query();
    $query_posts->query($args);
    ?>
    have_posts()) : $query_posts->the_post(); ?>
  • ” rel=”bookmark” title=””>




發表評論

腾讯彩票兑奖