让 wp_list_categories() 自定义 walker 进行分页

发布于 2024-10-09 17:09:36 字数 227 浏览 0 评论 0原文

我已经注册了自定义帖子类型,具有自定义分类法,一切都很好且清晰。

我希望我能以某种方式通过分页显示分类法的所有类别。

我正在使用自定义类别 Walker,并且正在考虑注册用于页面查询的自定义页面重写,并向类别 walker 添加一些代码以仅显示所需的间隔。我的方向正确吗?

此外,wp_list_categories 向类别 Walker 发送整个类别列表。有什么办法可以只得到所需的间隔吗?

I've got a custom post type registered, with custom taxonomies, everything good and clear.

I wish I could somehow display all the categories of the taxonomy with pagination.

I am using a custom category Walker and am thinking to register a custom page rewrite for page query, and add some code to the category walker to display only the desired interval. Am I on the right direction?

Also, wp_list_categories sends to the category Walker the entire list of categories. Is there any way to get only the desired interval?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一梦等七年七年为一梦 2024-10-16 17:09:36

在这个特定的设置中,没有。

但我找到了一个解决方法:我注册了一个函数,每次在分类法中添加类别时,该函数都会创建自定义类型的帖子。这样我就使用了自定义帖子类型的存档功能,该功能在 3.1-RC1 中提供。

function create_crew_post_on_term($term_id) {

$term = get_term($term_id, 'crew');

$post = array(
      'comment_status' => 'open',
      'ping_status' => 'open',
      'post_author' => 1,
      'post_content' => '',
      'post_date' => date('Y-m-d H:i:s'),
      'post_excerpt' => '',
      'post_name' => $term->slug,
      'post_status' => 'publish',
      'post_title' => $term->name,
      'post_type' => 'crew'
    );  

    wp_insert_post( $post );


}
add_action('created_crew', 'create_crew_post_on_term');

In this particular setup, no.

But I found a workaround: I registered a function that created a custom-type post each time I added a category in the taxonomy. That way I used the archive feature for custom post types, made available in 3.1-RC1.

function create_crew_post_on_term($term_id) {

$term = get_term($term_id, 'crew');

$post = array(
      'comment_status' => 'open',
      'ping_status' => 'open',
      'post_author' => 1,
      'post_content' => '',
      'post_date' => date('Y-m-d H:i:s'),
      'post_excerpt' => '',
      'post_name' => $term->slug,
      'post_status' => 'publish',
      'post_title' => $term->name,
      'post_type' => 'crew'
    );  

    wp_insert_post( $post );


}
add_action('created_crew', 'create_crew_post_on_term');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文