自定义分类归档仅对子集用户可见

时间:2014-11-24 作者:Marco Montanari

我有一个自定义分类法(课程),可以帮助在数据的不同视图之间划分帖子和其他自定义帖子类型。现在,我已经扩展了自定义分类法页面,并且可以看到该页面。

http://www.ascuoladiopencoesione.it/lesson/1-progettare/

您应该会看到一个空页面,这就是问题所在:似乎只有注册用户才能看到内容,这很奇怪,因为配置并没有执行任何强制操作。。。

谢谢

EDIT

这是自定义分类法的结构。自定义帖子类型为公文包\\u条目,在主题中(折叠)。。。对于其他分类法和东西没有问题,只是这不起作用。。。

function lessons() {

$labels = array(
    \'name\'                       => _x( \'Lessons\', \'Taxonomy General Name\', \'text_domain\' ),
    \'singular_name\'              => _x( \'Lesson\', \'Taxonomy Singular Name\', \'text_domain\' ),
    \'menu_name\'                  => __( \'Lesson\', \'text_domain\' ),
    \'all_items\'                  => __( \'All Lesson Lessons\', \'text_domain\' ),
    \'parent_item\'                => __( \'\', \'text_domain\' ),
    \'parent_item_colon\'          => __( \'\', \'text_domain\' ),
    \'new_item_name\'              => __( \'New Lesson\', \'text_domain\' ),
    \'add_new_item\'               => __( \'Add new Lesson\', \'text_domain\' ),
    \'edit_item\'                  => __( \'Edit Lesson\', \'text_domain\' ),
    \'update_item\'                => __( \'Update Lesson\', \'text_domain\' ),
    \'separate_items_with_commas\' => __( \'Separate Lessons with commas\', \'text_domain\' ),
    \'search_items\'               => __( \'Search Lessons\', \'text_domain\' ),
    \'add_or_remove_items\'        => __( \'Add or remove Lessons\', \'text_domain\' ),
    \'choose_from_most_used\'      => __( \'Choose from the most used Lessons\', \'text_domain\' ),
    \'not_found\'                  => __( \'Not Found\', \'text_domain\' ),
);
$args = array(
    \'labels\'                     => $labels,
    \'hierarchical\'               => true,
    \'public\'                     => true,
    \'show_ui\'                    => true,
    \'show_admin_column\'          => true,
    \'has_archive\'                => true,
    \'show_in_nav_menus\'          => true,
    \'show_tagcloud\'              => true
);
register_taxonomy( \'lesson\', array( \'post\',\'portfolio\',\'link_category\', \'forum\', "topic" ), $args );

}

// Hook into the \'init\' action
add_action( \'init\', \'lessons\', 0 );

EDIT added plugins

EDIT - how do I get the posts

$args = array(
    \'posts_per_page\'   => -1,
    \'offset\'           => 0,
    \'lesson\'           => $wp_query->queried_object->name,
    \'orderby\'          => \'post_date\',
    \'order\'            => \'DESC\',
    \'post_type\'        => array(\'post\', \'portfolio\', \'forum\', \'link\', \'topic\', \'link_category\'),
    \'post_status\'      => \'publish\',
    \'suppress_filters\' => true ); 
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post );

1 个回复
最合适的回答,由SO网友:Marco Montanari 整理而成

我根本不知道为什么会这样。但事实确实如此。供将来参考。。。

function remove_meta( $query ) {
    $query->set( \'meta_query\', false );
}
add_action( \'pre_get_posts\', \'remove_meta\' );

结束

相关推荐