Reputation: 1
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');
?>
Upvotes: 0
Views: 34
Reputation: 1508
"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.
Upvotes: 1