中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

WP程序調(diào)用最新文章 熱門文章 相關(guān)文章 隨機(jī)文章代碼

2018-11-02    來源:學(xué)做網(wǎng)站論壇

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬Linux鏡像隨意使用

wordpress程序是一個(gè)比較高效的網(wǎng)站制作程序,在學(xué)員學(xué)習(xí)如何做網(wǎng)站的時(shí)候,可以使用wp程序作為自己的首選建站程序,只要熟練的運(yùn)用它的網(wǎng)站代碼就可以制作出自己需要的網(wǎng)站來。

下面是學(xué)做網(wǎng)站論壇提供關(guān)于wordpress程序調(diào)用最新文章、熱門文章、相關(guān)文章、隨機(jī)文章代碼,供廣大學(xué)習(xí)網(wǎng)站制作培訓(xùn)課程的學(xué)員共享。

wordpress最新文章代碼:

<?php?$rand_posts?=?get_posts('numberposts=10&orderby=date');foreach($rand_posts?as?$post)?:??>
<li><a?href="<?php?the_permalink();??>">?<?php?echo?mb_strimwidth(get_the_title(),?0,?32,?'');??></a></li>
<?php?endforeach;?>

numberposts=10最新10篇文章
orderby=date按日期調(diào)用

wordpress相關(guān)文章代碼:(調(diào)用同一分類)

<?php
$cats = wp_get_post_categories($post->ID);
if ($cats) {
$args = array(
'category__in' => array( $cats[0] ),
'post__not_in' => array( $post->ID ),
'showposts' => 6,
'caller_get_posts' => 1
);
query_posts($args);
if (have_posts()) :
while (have_posts()) : the_post(); update_post_caches($posts); ?>
<li><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; else : ?>
<li> 暫無相關(guān)文章</li>
<?php endif; wp_reset_query(); } ?>

標(biāo)簽相關(guān)文章調(diào)用:(調(diào)用相同標(biāo)簽下的文章)

<?php
global $post;
$post_tags = wp_get_post_tags($post->ID);
if ($post_tags) {
? foreach ($post_tags as $tag) {
?   // 獲取標(biāo)簽列表
?   $tag_list[] .= $tag->term_id;
? }

? // 隨機(jī)獲取標(biāo)簽列表中的一個(gè)標(biāo)簽
? $post_tag = $tag_list[ mt_rand(0, count($tag_list) - 1) ];

? // 該方法使用 query_posts() 函數(shù)來調(diào)用相關(guān)文章,以下是參數(shù)列表
? $args = array(
?       'tag__in' => array($post_tag),
?       'category__not_in' => array(NULL),  // 不包括的分類ID
?       'post__not_in' => array($post->ID),
?       'showposts' => 10,                         // 顯示相關(guān)文章數(shù)量
?       'caller_get_posts' => 1
?   );
? query_posts($args);

? if (have_posts()) {
?   while (have_posts()) {
?     the_post(); update_post_caches($posts); ?>
?   <li>* <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
<?php
?   }
? }
? else {
?   echo '<li>* 暫無相關(guān)文章</li>';
? }
? wp_reset_query();
}
else {
? echo '<li>* 暫無相關(guān)文章</li>';
}
?>

wordpress隨機(jī)文章代碼:

<?php $rand_posts = get_posts('numberposts=10& category=1&orderby=rand');foreach($rand_posts as $post) : ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endforeach;?>

numberposts=10?最新10篇文章
orderby=date?按日期調(diào)用
category=1?只調(diào)用某個(gè)分類目錄下的文章

wordpress熱門文章代碼:

wordpress調(diào)用熱門文章(熱評(píng)文章)

標(biāo)簽: 代碼 建站 建站程序 網(wǎng)站制作

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:wordpress調(diào)用指定分類下的子分類

下一篇:如何將wordpress英文版轉(zhuǎn)成中文版