wordpress中的loop真的非常的强大,以前都有点忽略它,越来越多的做了wordpress主题之后才发现使用它能解决很多很多比较复杂一点的要求。
我们以index.php页面来做案例讲解,首先,打开index.php页面,在循环之前加入以下代码:
<?php
function filter_where($where = ”) {
$where .= ” AND post_date >= ’2009-05-01′ AND post_date <= ’2009-05-15′”;
return $where;
}
add_filter(‘posts_where’, ‘filter_where’);
query_posts($query_string);
?>
本文深入探讨了 WordPress 中 loop 的强大功能,并通过 index.php 页面实例展示了如何利用它解决复杂需求。重点介绍了 query_posts 函数的使用,以及如何在循环前添加特定查询条件,以获取过滤后的结果。
500

被折叠的 条评论
为什么被折叠?



