0
votes

I have created a custom post type 'Products' and it appears as a separate category 'Products' on the dashboard. I am following some instructions on how to edit the custom posts and it is telling me to edit them through posts->all posts so that I can get the custom fields as part of the screen view, however I do not see any of my instances of 'product' posts when I access 'all posts'. Are all posts -custom and standard- supposed to appear under all posts? Did I do something wrong when I set up my 'product' posts?

 <?php

function create_product_post_type() {
  $labels = array(
   'name'           => 'Products',
   'singular_name'  => 'Product'
  );
  $args = array(
   'labels'     => $labels,
   'public'     => true,
   'supports'   => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
   'taxonomies' => array( 'category' )
  );
  register_post_type( 'product', $args ); 
}

add_action( 'init', 'create_product_post_type' );

function add_product_to_archives( $wp_query ) {

    $types_array = array( 'post', 'product' );

    if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
        set_query_var( 'post_type', $types_array );
    }
}

add_action('pre_get_posts', 'add_product_to_archives');

?>
1
No. Custom posts are NOT supposed to appear under "Posts" => "All Posts". Your products custom posts should appear under "Products" => "All Products", and that's where you can add, edit, etc. And I believe you incorrectly used the term "category": .... appears as a seaprate category in the dashboard ... - what you probably mean is it appears as a separate menu item in the dashboard menu. Which is where it is supposed to show. - random_user_name

1 Answers

1
votes

"Posts" are a different post type than your custom post type "Products", so it will not appear in the "Posts" menu. Your custom post type will have its own custom admin menu.