0

I'm in need to create a simple real estate listing taxonomy with custom post type for properties that I'd be listing on a website.

I don't need any of the fancy things you see on some of the real estate websites around and I want to learn how to do this to improve it in the future when I get more coding skills.

I'm attaching a picture on how the property single page and archive layout needs to look property display I want to know where do I start learning to accomplish this.

Thank you in advance.

1 Answer 1

1

You will need to do the following:

-- First, create a child theme if you haven't done so already. This will save you from losing all your hard work if your main theme needs to get updated. More information on how to this can be found here: https://codex.wordpress.org/Child_Themes

-- Then, go to your functions.php and create your custom post type. IT can look something like this:

//custom post type
/*
* Creating a function to create our CPT
*/

function my_custom_post_type() {

// Set UI labels for Custom Post Type
$labels = array(
    'name'                => _x( 'Properties', 'Post Type General Name', 'custompsotype' ),
    'singular_name'       => _x( 'Property', 'Post Type Singular Name', 'custompsotype' ),
    'menu_name'           => __( 'Properties', 'custompsotype' ),
    'parent_item_colon'   => __( 'Parent Property', 'custompsotype' ),
    'all_items'           => __( 'All Properties', 'custompsotype' ),
    'view_item'           => __( 'View Property', 'custompsotype' ),
    'add_new_item'        => __( 'Add New Property', 'custompsotype' ),
    'add_new'             => __( 'Add New', 'custompsotype' ),
    'edit_item'           => __( 'Edit Property', 'custompsotype' ),
    'update_item'         => __( 'Update Property', 'custompsotype' ),
    'search_items'        => __( 'Search Property', 'custompsotype' ),
    'not_found'           => __( 'Not Found', 'custompsotype' ),
    'not_found_in_trash'  => __( 'Not found in Trash', 'custompsotype' ),
);

// Set other options for Custom Post Type

$args = array(
    'label'               => __( 'properties', 'custompsotype' ),
    'description'         => __( 'Properties', 'custompsotype' ),
    'labels'              => $labels,
    // Features this CPT supports in Post Editor
    'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', 'custom-fields', ),
    // You can associate this CPT with a taxonomy or custom taxonomy. 
    'taxonomies'          => array( 'genres' ),
    /* A hierarchical CPT is like Pages and can have
    * Parent and child items. A non-hierarchical CPT
    * is like Posts.
    */  
    'hierarchical'        => false,
    'public'              => true,
    'show_ui'             => true,
    'show_in_menu'        => true,
    'show_in_nav_menus'   => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 5,
    'can_export'          => true,
    'has_archive'         => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'menu_icon'           => 'dashicons-format-aside',
    'capability_type'     => 'page',
);

// Registering your Custom Post Type
register_post_type( 'properties', $args );

}

/* Hook into the 'init' action so that the function
* Containing our post type registration is not 
* unnecessarily executed. 
*/

add_action( 'init', 'my_custom_post_type', 0 );

-- The following will create your new post type. You can now add properties to it, as well as property categories (e.g. "properties by the sea") the exact same way you do for normal posts.

-- You can modify the look/code/layout of the new post type by creating new php files, one for the list of properties, named archive-properties.php and one for a single property, named single-properties.php. You can find more here: https://codex.wordpress.org/Post_Type_Templates .

-- In order to add custom fields to your properties, I recommend using Advanced Custom Fields(https://www.advancedcustomfields.com/), as it is,in my opinion, the easiest option for beginners and comes with plenty of options and great documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.