【问题标题】:wp-admin list only parent postswp-admin 仅列出父帖子
【发布时间】:2013-11-18 08:40:00
【问题描述】:

当管理员创建一个包含五个自定义字段的帖子时,我创建了 5 个带有 post_parent id 的帖子到主帖子。但是这 5 个帖子也显示在我想隐藏的帖子列表中。

在 /wp-admin/edit.php 中,wordpress 在 All/Publish 下显示所有帖子(父和子)我只想显示 父帖子 具有 post_type = post 因为我也在使用其他帖子类型,但只想更改 post_type = post 的视图。

我知道为此我必须编辑核心文件,无论我可以。在wp-admin/includes/class-wp-list-table.php搜索后发现

    /**
     * Generate the <tbody> part of the table
     *
     * @since 3.1.0
     * @access protected
     */
    function display_rows_or_placeholder() {
        if ( $this->has_items() ) {
            $this->display_rows();
        } else {
            list( $columns, $hidden ) = $this->get_column_info();
            echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
            $this->no_items();
            echo '</td></tr>';
        }
    }

它为帖子列表创建行,但我找不到在哪里设置条件和自定义查询:

IF (post_type == 'post'){
    // list only parent posts
}else{
    // do default behavior
}

我搜索了将近 3 小时,但没有找到解决方案。好的,如果不可能,那么我们可以为 Pages 父/子关系等帖子显示相同的层次结构。

【问题讨论】:

  • 不,在 wordpress 中无需更改任何核心文件以进行任何更改。 wordpress 提供钩子概念
  • 如果是这样,那么我如何从 post_type == 'post' 的帖子列表中隐藏子帖子
  • post_type='post'中的父子如何管理?
  • 对不起,你说的是页面吗?什么是父/子 POST ??
  • 当管理员创建一个包含五个自定义字段的帖子时,我创建了 5 个带有 post_parent id 的帖子到主帖子。但是这 5 个帖子也显示在我想隐藏的帖子列表中。

标签: wordpress


【解决方案1】:

经过大约 4 小时的研究,我发现了 wordpress: how to add hierarchy to posts

好像wordpress需要实现这样的功能。

【讨论】:

  • 不,帖子是按时间顺序排列的,页面是分层的。如果我们想要不同的东西,我们会使用自定义帖子类型或像您一样调整系统;)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-15
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多