WordPress

推荐列表 站点导航

当前位置:首页 > 建站教程 > WordPress >

wordpress调用特定文章列表的技巧分享

来源:网络整理  作者:  发布时间:2020-12-19 05:25
在wordpress主题制作开发中经常会需要在特定的页面中调用出指定的文章或文章列表,接下来教大家如何调用出wordpre...

在 wordpress主题制作开发 中经常会需要在特定的页面中调用出指定的文章或文章列表,接下来教大家如何调用出 wordpress文章列表 。

调用网站最新文章:

<?php
query_posts('showposts=10&orderby=new'); //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('showposts=10&orderby=rand'); //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('showposts=10&cat=1'); //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('showposts=10&cat=-1'); //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调用特定文章列表的技巧分享 (https://www.wpmee.com/) WordPress使用教程 第1张

相关热词: 调用 技巧

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jz/wp/5479.shtml

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

wordpress调用特定文章列表的技巧分享

2020-12-19 编辑:

在 wordpress主题制作开发 中经常会需要在特定的页面中调用出指定的文章或文章列表,接下来教大家如何调用出 wordpress文章列表 。

调用网站最新文章:

<?php
query_posts('showposts=10&orderby=new'); //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('showposts=10&orderby=rand'); //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('showposts=10&cat=1'); //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('showposts=10&cat=-1'); //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调用特定文章列表的技巧分享 (https://www.wpmee.com/) WordPress使用教程 第1张

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jz/wp/5479.shtml

相关文章

风云图片

推荐阅读

返回WordPress频道首页