Real Estate Properties Post Type
Registers a "Properties" post type with Property Type and Property Status taxonomies (for sale, for rent, sold) for estate agents.
Opens WPIDE on
Code
// Names used in labels and URLs: edit to suit.
$wpide_type = array(
'name' => 'property', // Internal name: lowercase, max 20 characters, never change it once you have content.
'singular' => 'Property',
'plural' => 'Properties',
'slug' => 'properties',
);
add_action( 'init', function () use ( $wpide_type ) {
$s = $wpide_type['singular'];
$p = $wpide_type['plural'];
register_post_type( $wpide_type['name'], array(
'labels' => array(
'name' => $p,
'singular_name' => $s,
'menu_name' => $p,
'add_new_item' => "Add New $s",
'edit_item' => "Edit $s",
'new_item' => "New $s",
'view_item' => "View $s",
'view_items' => "View $p",
'all_items' => "All $p",
'search_items' => "Search $p",
'not_found' => 'Nothing found.',
'not_found_in_trash' => 'Nothing found in Trash.',
'archives' => "$s Archives",
'attributes' => "$s Attributes",
'insert_into_item' => "Insert into $s",
'uploaded_to_this_item' => "Uploaded to this $s",
'item_published' => "$s published.",
'item_updated' => "$s updated.",
),
'public' => true,
'has_archive' => $wpide_type['slug'],
'rewrite' => array( 'slug' => $wpide_type['slug'], 'with_front' => false ),
'show_in_rest' => true,
'menu_icon' => 'dashicons-admin-home',
'menu_position' => 37,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions' ),
) );
register_taxonomy( 'property_type', $wpide_type['name'], array(
'labels' => array(
'name' => 'Property Types',
'singular_name' => 'Property Type',
'menu_name' => 'Property Types',
'all_items' => 'All Property Types',
'edit_item' => 'Edit Property Type',
'view_item' => 'View Property Type',
'update_item' => 'Update Property Type',
'add_new_item' => 'Add New Property Type',
'new_item_name' => 'New Property Type Name',
'search_items' => 'Search Property Types',
'not_found' => 'No property types found.',
'parent_item' => 'Parent Property Type',
),
'hierarchical' => true,
'public' => true,
'rewrite' => array( 'slug' => 'property-type', 'with_front' => false ),
'show_admin_column' => true,
'show_in_rest' => true,
) );
register_taxonomy( 'property_status', $wpide_type['name'], array(
'labels' => array(
'name' => 'Property Statuses',
'singular_name' => 'Property Status',
'menu_name' => 'Property Statuses',
'all_items' => 'All Property Statuses',
'edit_item' => 'Edit Property Status',
'view_item' => 'View Property Status',
'update_item' => 'Update Property Status',
'add_new_item' => 'Add New Property Status',
'new_item_name' => 'New Property Status Name',
'search_items' => 'Search Property Statuses',
'not_found' => 'No property statuses found.',
'parent_item' => 'Parent Property Status',
),
'hierarchical' => true,
'public' => true,
'rewrite' => array( 'slug' => 'property-status', 'with_front' => false ),
'show_admin_column' => true,
'show_in_rest' => true,
) );
} );
Notes
Add the Property Details meta box snippet for price, bedrooms and floor area.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.