首頁  >  文章  >  CMS教程  >  wordpress怎麼呼叫特定文章列表

wordpress怎麼呼叫特定文章列表

藏色散人
藏色散人原創
2019-12-28 09:48:233447瀏覽

wordpress怎麼呼叫特定文章列表

wordpress怎麼呼叫特定文章清單?

在 wordpress主題製作開發 中經常會需要在特定的頁面中調用出指定的文章或文章列表,接下來教大家如何調用出 wordpress文章列表 。

  推薦:《wordpress教學

呼叫網站最新文章:

程式碼如下:

<?php
query_posts(&#39;showposts=10&orderby=new&#39;); 
//showposts=10表示10篇
while(have_posts()): the_post();
?>
<li><a href="<?php the_permalink(); ?>"target="_blank"><?php the_title() ?></a></li> 
//这里可以写成你自己需要的样式
<?php endwhile; ?>

呼叫隨機文章:

程式碼如下:

<?php
query_posts(&#39;showposts=10&orderby=rand&#39;); 
//showposts=10表示10篇
while(have_posts()): the_post();
?>
<li>
<a href="<?php the_permalink(); ?>"target="_blank"><?php the_title() ?></a>
</li> 
//这里可以写成你自己需要的样式
<?php 
endwhile; 
?>

呼叫某個分類下的最新文章:

程式碼如下:

<?php
query_posts(&#39;showposts=10&cat=1&#39;); 
//cat=1为调用ID为1的分类下文章
while(have_posts()) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>"title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php 
endwhile; 
?>

排除某個分類下的文章:

程式碼如下:

<?php
query_posts(&#39;showposts=10&cat=-1&#39;); 
//cat=-1为排除ID为1的分类下文章
while(have_posts()) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>"title="<?php the_title(); ?>"><?php the_title(); ?></a>
</li>
<?php 
endwhile; 
?>

以上就是文章列表的呼叫方法,可以將範例中的程式碼結合起來達到你需要的效果。

以上是wordpress怎麼呼叫特定文章列表的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn