0

After severall search, maybe without the right english terms, I come here to find an answer to my problem.

I have a theme that I created on my website, everything is working perfectly for the last 6 months.

I also have a custom post type to add some twitch channel on my website and display them.

Yesterday, I created a new custom post type to write some fast news so just the minimal content : title, content, author and revisions.

But when I add this one to my website, the Posts, Streams, News and Pages list become empty with a "not found" message even when there is some content with this post type.

Like this : Empty list

I think I already had this bug a long time ago but I can't remember how to fix it.

I tried to desactivate my every plugin one by one but the bug was still there.

Here is the code of my Custom Post Type (created with GenerateWP to save a lot of time) :

if ( ! function_exists('news_post') ) {

function news_post() {
$labels = array(
    'name'                  => _x( 'News', 'Post Type General Name', 'text_domain' ),
    'singular_name'         => _x( 'News', 'Post Type Singular Name', 'text_domain' ),
    'menu_name'             => __( 'News', 'text_domain' ),
    'name_admin_bar'        => __( 'News', 'text_domain' ),
    'archives'              => __( 'Item Archives', 'text_domain' ),
    'parent_item_colon'     => __( 'Parent News:', 'text_domain' ),
    'all_items'             => __( 'All News', 'text_domain' ),
    'add_new_item'          => __( 'Add New News', 'text_domain' ),
    'add_new'               => __( 'Add News', 'text_domain' ),
    'new_item'              => __( 'New News', 'text_domain' ),
    'edit_item'             => __( 'Edit News', 'text_domain' ),
    'update_item'           => __( 'Update News', 'text_domain' ),
    'view_item'             => __( 'View News', 'text_domain' ),
    'search_items'          => __( 'Search News', 'text_domain' ),
    'not_found'             => __( 'Not found', 'text_domain' ),
    'not_found_in_trash'    => __( 'Not found in Trash', 'text_domain' ),
    'featured_image'        => __( 'Featured Image', 'text_domain' ),
    'set_featured_image'    => __( 'Set featured image', 'text_domain' ),
    'remove_featured_image' => __( 'Remove featured image', 'text_domain' ),
    'use_featured_image'    => __( 'Use as featured image', 'text_domain' ),
    'insert_into_item'      => __( 'Insert into News', 'text_domain' ),
    'uploaded_to_this_item' => __( 'Uploaded to this News', 'text_domain' ),
    'items_list'            => __( 'News list', 'text_domain' ),
    'items_list_navigation' => __( 'News list navigation', 'text_domain' ),
    'filter_items_list'     => __( 'Filter News list', 'text_domain' ),
);
$args = array(
    'label'                 => __( 'News', 'text_domain' ),
    'description'           => __( 'News Post Type', 'text_domain' ),
    'labels'                => $labels,
    'supports'              => array( 'title', 'editor', 'author', 'revisions', ),
    'hierarchical'          => false,
    'public'                => true,
    'show_ui'               => true,
    'show_in_menu'          => true,
    'menu_position'         => 5,
    'show_in_admin_bar'     => true,
    'show_in_nav_menus'     => true,
    'can_export'            => true,
    'has_archive'           => true,        
    'exclude_from_search'   => false,
    'publicly_queryable'    => true,
    'capability_type'       => 'post',
);
register_post_type( 'post_type', $args );

}
add_action( 'init', 'news_post', 0 );

}

Any idea about how to fix that?

2 Answers 2

0

What you're doing there is registering a new post type called "post_type" change this name to something else - such as:

register_post_type( 'fast_news', $args );

See if that works for you?

1
  • You know what? I am just stupid. You found the problem I had with my other Custom Post Type the first time and I just didn't change it on my saved snippet but just changed it in the function.php... Thank you, it's working now!
    – Anaon
    Aug 22, 2016 at 23:19
0

Note that as I got the exact same issue as in your screenshot (counter of items showed items, but NO items are shown in the list/table, not even my own).

Turned out that the custom theme had a hidden "feature" ..

    add_action( 'pre_get_posts', 'my_change_sort_order');
    function my_change_sort_order($query){
        if(is_archive()):
           //Set the order ASC or DESC
           $query->set('meta_key', 'score');
           //Set the orderby
           $query->set('orderby', 'meta_value');
        endif;    
    };

which essentially adds a 'score' fieldname requirement in the SQL query. and thus will result in zero results.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.