【问题标题】:Getting wp_list_categories() custom walker to paginate让 wp_list_categories() 自定义walker分页
【发布时间】:2011-06-02 13:27:56
【问题描述】:

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

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

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

此外,wp_list_categories 将整个类别列表发送给类别 Walker。有没有办法只获得所需的间隔?

【问题讨论】:

  • 你有没有想过这个问题?我正在尝试做同样的事情。

标签: wordpress taxonomy categories pagination wp-list-categories


【解决方案1】:

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

但我找到了一种解决方法:我注册了一个函数,每次我在分类中添加一个类别时都会创建一个自定义类型的帖子。这样我就使用了自定义帖子类型的存档功能,在 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');

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-12
    • 2014-08-02
    • 1970-01-01
    • 1970-01-01
    • 2011-04-05
    • 2021-11-06
    • 1970-01-01
    相关资源
    最近更新 更多