Custom Post type URLs
-
Hello,
First attempt at Custom Post Types and Taxonomies. Seems to be having a URL issue.
My CPT is “Properties” and my Taxonomy is “Property Types”. All seems to be fine on Admin dashboard and I added two proerty types;
1. Land for Sale
2. Farms for SaleI can see these ok on front end but the URLs are not what I was hoping.
The actual property listing can be viewed here: http://noeloconnor.com/property/castleroberts-adare-limerick/
I would like it to appear as http://noeloconnor.com/property/farms-for-sale/castleroberts-adare-limerick/
What I was hoping would be its parent page can be seen here: http://noeloconnor.com/property_types/farms-for-sale/
I would like the parent page to appear as http://noeloconnor.com/property/farms-for-sale/ if possible
It just seems to be that from an SEO point of view it is not correct. I was hoping to have the URL structure similar to how the regular domainname/categoryname/postname structure
Below is the Custom Post Type code I entered in my functions.php code for my child theme;
// Custom Post Type for Property add_action( 'init', 'register_cpt_property' ); function register_cpt_property() { $labels = array( 'name' => _x( 'Properties', 'property' ), 'singular_name' => _x( 'Property', 'property' ), 'add_new' => _x( 'Add New', 'property' ), 'all_items' => _x( 'Properties', 'property' ), 'add_new_item' => _x( 'Add New Property', 'property' ), 'edit_item' => _x( 'Edit Property', 'property' ), 'new_item' => _x( 'New Property', 'property' ), 'view_item' => _x( 'View Property', 'property' ), 'search_items' => _x( 'Search Properties', 'property' ), 'not_found' => _x( 'No properties found', 'property' ), 'not_found_in_trash' => _x( 'No properties found in Trash', 'property' ), 'parent_item_colon' => _x( 'Parent Property:', 'property' ), 'menu_name' => _x( 'Properties', 'property' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true ); register_post_type( 'property', $args ); }
Below is the Taxonomy code I entered in my functions.php code for my child theme;
// Taxonomy for Property Types add_action( 'init', 'register_taxonomy_property_types' ); function register_taxonomy_property_types() { $labels = array( 'name' => _x( 'Property Types', 'property_types' ), 'singular_name' => _x( 'Property Type', 'property_types' ), 'search_items' => _x( 'Search Property Types', 'property_types' ), 'popular_items' => _x( 'Popular Property Types', 'property_types' ), 'all_items' => _x( 'All Property Types', 'property_types' ), 'parent_item' => _x( 'Parent Property Type', 'property_types' ), 'parent_item_colon' => _x( 'Parent Property Type:', 'property_types' ), 'edit_item' => _x( 'Edit Property Type', 'property_types' ), 'update_item' => _x( 'Update Property Type', 'property_types' ), 'add_new_item' => _x( 'Add New Property Type', 'property_types' ), 'new_item_name' => _x( 'New Property Type', 'property_types' ), 'separate_items_with_commas' => _x( 'Separate property types with commas', 'property_types' ), 'add_or_remove_items' => _x( 'Add or remove property types', 'property_types' ), 'choose_from_most_used' => _x( 'Choose from the most used property types', 'property_types' ), 'menu_name' => _x( 'Property Types', 'property_types' ), ); $args = array( 'labels' => $labels, 'public' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_tagcloud' => false, 'show_admin_column' => false, 'hierarchical' => true, 'rewrite' => true, 'query_var' => true ); register_taxonomy( 'property_types', array('property'), $args ); }
Any help would be so much appreciated.
- The topic ‘Custom Post type URLs’ is closed to new replies.