查看: 28|回复: 0

[教程] wordpress自定义循环列表的php代码

[复制链接]

2

主题

0

回帖

0

积分

热心网友

金币
0
阅读权限
220
精华
0
威望
0
贡献
0
在线时间
0 小时
注册时间
2010-11-27
发表于 2023-8-21 00:00:00 | 显示全部楼层 |阅读模式

代码如下:


<?php $epaged = (get_query_var('paged')) ? get_query_var('paged') : 1; 
$temp = $wp_query; 
$wp_query = null; 
?> 
<?php $wp_query = new WP_Query('category_name=portfolio&tag=web&showposts=5&paged=' . $epaged);?> 
<?php if ($wp_query->have_posts()) : ?> 
<section> 
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?> 
<article> 
<time datetime="<?php the_time('Y-m-d') ?>" pubdate><?php the_time('F jS, Y') ?></time> 
<h1> 
<a rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"> 
<?php the_title(); ?> 
</a> 
</h1> 
<section> 
<?php the_content(); ?> 
</secion> 
</article> 
<?php endwhile;?> 
<div> 
<?php 
next_posts_link( __( '&larr; Older posts', 'twentyten' ) ); 
previous_posts_link( __( 'Newer posts &rarr;', 'twentyten' ) ); 
$wp_query = null; $wp_query = $temp; 
?> 
</div> 
</section> 
<?php 
endif; 
?> 

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

相关侵权、举报、投诉及建议等,请发 E-mail:qiongdian@foxmail.com

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部