How to list Custom Post Type on permalink
-
Hi,
I’m having problems getting my post to list a custom_post_type (apartment). When reading the apartment single post I get this permalink structure:
https://www.blog.com/apartments/my-apartment-title
But when I change the url to:
https://www.blog.com/apartments/
It gives me error 404.
On the post registration I use this code
function register_apartments () { # Register post type apartment register_post_type ( 'apartment', array ( '_builtin' => false, 'labels' => array ( 'name' => _x( 'Apartments', 'post type general name', MYSITE_ADMIN_TEXTDOMAIN ), 'singular_name' => _x( 'Apartment', 'post type singular name', MYSITE_ADMIN_TEXTDOMAIN ), 'add_new' => _x( 'Add New', 'apartment', MYSITE_ADMIN_TEXTDOMAIN ), 'add_new_item' => __( 'Add New Apartment', MYSITE_ADMIN_TEXTDOMAIN ), 'edit_item' => __( 'Edit Apartment', MYSITE_ADMIN_TEXTDOMAIN ), 'new_item' => __( 'New Apartment', MYSITE_ADMIN_TEXTDOMAIN ), 'view_item' => __( 'View Apartment', MYSITE_ADMIN_TEXTDOMAIN ), 'search_items' => __( 'Search Apartments', MYSITE_ADMIN_TEXTDOMAIN ), 'not_found' => __( 'No apartments found', MYSITE_ADMIN_TEXTDOMAIN ), 'not_found_in_trash' => __( 'No apartments found in Trash', MYSITE_ADMIN_TEXTDOMAIN ), 'parent_item_colon' => '' ), 'description' => __( 'Apartment description' ), 'singular_label' => __( 'Apartment', MYSITE_ADMIN_TEXTDOMAIN ), 'capability_type' => 'delete_published_posts', 'menu_position' => 3, 'exclude_from_search' => false, 'capability_type' => 'post', 'hierarchical' => false, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'ep_mask' => 1, 'rewrite' => array ( 'slug' => 'apartments', 'with_front' => false ), 'query_var' => true, 'taxonomies' => array ( 'category' ), 'supports' => array ( 'title', 'editor', 'thumbnail', 'revisions' )//, 'excerpt', 'comments', 'custom-fields' ) ) ); } add_action ( 'init', 'register_post_type' );
Any help would be appreciated.
Thanks
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘How to list Custom Post Type on permalink’ is closed to new replies.