I made a custom post type , and an archive page for the post type. I don't know if there is a url where I can access this archive page? I would like to have a page where all the "posts" (products) for this archive is listed. But they don't need to be organized into post dates (what month and day).
Here is the code
function register_products_post_type() {
$labels_array = [
'name' => __( 'Produkter', 'Divi' ),
'singular_name' => _x( 'Produkt', 'post type singular name', 'Divi' ),
'menu_name' => _x( 'Products', 'admin menu', 'Divi' ),
'name_admin_bar' => _x( 'Product', 'add new on admin bar', 'Divi' ),
'add_new' => _x( 'Add New', 'product', 'Divi' ),
'add_new_item' => __( 'Add New Product', 'Divi' ),
'new_item' => __( 'New Product', 'Divi' ),
'edit_item' => __( 'Edit Product', 'Divi' ),
'view_item' => __( 'View Product', 'Divi' ),
'all_items' => __( 'All Products', 'Divi' ),
'search_items' => __( 'Search Products', 'Divi' ),
'parent_item_colon' => __( 'Parent Products:', 'Divi' ),
'not_found' => __( 'No products found.', 'Divi' ),
'not_found_in_trash' => __( 'No products found in Trash.', 'Divi' )
];
$args = array(
'public' => true,
'labels' => $labels_array,
'description' => __( 'beskrivning.', 'Divi' ),
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);
register_post_type( 'products', $args );
}
add_action( 'init', 'register_products_post_type' );
I have an archive.php and an archive-products.php. So the main thing I need is a url to the archive page for the post type. Then I need to edit that archive to display the products.
edit: when I try to access the page "/products" I reach a 404 page.
Another way I suppose would be to create a normal custom page where I would list the products, and use it as an "archive". I don't know if that would be the better alternative.