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

wordpress怎麼呼叫特定文章列表

藏色散人
發布: 2022-04-15 16:49:22
原創
3626 人瀏覽過

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
最新問題
java - wordpress 建置站 後端一定要用php 麼?
來自於 1970-01-01 08:00:00
0
0
0
基於Nginx的Wordpress安裝失敗?
來自於 1970-01-01 08:00:00
0
0
0
wordpress 移動到子目錄,nginx 如何配置
來自於 1970-01-01 08:00:00
0
0
0
wordpress怎麼在PHP工具箱安裝
來自於 1970-01-01 08:00:00
0
0
0
安裝完wordpress 後出現這個錯誤
來自於 1970-01-01 08:00:00
0
0
0
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板