Step 2.1: Register Property custom post type
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -28,3 +28,6 @@ require_once HOMEPROZ_DIR . '/inc/enqueue.php';
|
|||||||
|
|
||||||
// Template helper functions
|
// Template helper functions
|
||||||
require_once HOMEPROZ_DIR . '/inc/template-functions.php';
|
require_once HOMEPROZ_DIR . '/inc/template-functions.php';
|
||||||
|
|
||||||
|
// Custom post types and taxonomies
|
||||||
|
require_once HOMEPROZ_DIR . '/inc/custom-post-types.php';
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Custom Post Types
|
||||||
|
*
|
||||||
|
* @package HomeProz
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Prevent direct access
|
||||||
|
if (!defined('ABSPATH')) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register Property Custom Post Type
|
||||||
|
*/
|
||||||
|
function homeproz_register_property_cpt() {
|
||||||
|
$labels = array(
|
||||||
|
'name' => _x('Properties', 'Post type general name', 'homeproz'),
|
||||||
|
'singular_name' => _x('Property', 'Post type singular name', 'homeproz'),
|
||||||
|
'menu_name' => _x('Properties', 'Admin Menu text', 'homeproz'),
|
||||||
|
'name_admin_bar' => _x('Property', 'Add New on Toolbar', 'homeproz'),
|
||||||
|
'add_new' => __('Add New', 'homeproz'),
|
||||||
|
'add_new_item' => __('Add New Property', 'homeproz'),
|
||||||
|
'new_item' => __('New Property', 'homeproz'),
|
||||||
|
'edit_item' => __('Edit Property', 'homeproz'),
|
||||||
|
'view_item' => __('View Property', 'homeproz'),
|
||||||
|
'all_items' => __('All Properties', 'homeproz'),
|
||||||
|
'search_items' => __('Search Properties', 'homeproz'),
|
||||||
|
'parent_item_colon' => __('Parent Properties:', 'homeproz'),
|
||||||
|
'not_found' => __('No properties found.', 'homeproz'),
|
||||||
|
'not_found_in_trash' => __('No properties found in Trash.', 'homeproz'),
|
||||||
|
'featured_image' => _x('Property Featured Image', 'Overrides the "Featured Image" phrase', 'homeproz'),
|
||||||
|
'set_featured_image' => _x('Set featured image', 'Overrides the "Set featured image" phrase', 'homeproz'),
|
||||||
|
'remove_featured_image' => _x('Remove featured image', 'Overrides the "Remove featured image" phrase', 'homeproz'),
|
||||||
|
'use_featured_image' => _x('Use as featured image', 'Overrides the "Use as featured image" phrase', 'homeproz'),
|
||||||
|
'archives' => _x('Property archives', 'The post type archive label used in nav menus', 'homeproz'),
|
||||||
|
'insert_into_item' => _x('Insert into property', 'Overrides the "Insert into post" phrase', 'homeproz'),
|
||||||
|
'uploaded_to_this_item' => _x('Uploaded to this property', 'Overrides the "Uploaded to this post" phrase', 'homeproz'),
|
||||||
|
'filter_items_list' => _x('Filter properties list', 'Screen reader text', 'homeproz'),
|
||||||
|
'items_list_navigation' => _x('Properties list navigation', 'Screen reader text', 'homeproz'),
|
||||||
|
'items_list' => _x('Properties list', 'Screen reader text', 'homeproz'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$args = array(
|
||||||
|
'labels' => $labels,
|
||||||
|
'public' => true,
|
||||||
|
'publicly_queryable' => true,
|
||||||
|
'show_ui' => true,
|
||||||
|
'show_in_menu' => true,
|
||||||
|
'query_var' => true,
|
||||||
|
'rewrite' => array('slug' => 'properties', 'with_front' => false),
|
||||||
|
'capability_type' => 'post',
|
||||||
|
'has_archive' => true,
|
||||||
|
'hierarchical' => false,
|
||||||
|
'menu_position' => 5,
|
||||||
|
'menu_icon' => 'dashicons-building',
|
||||||
|
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
|
||||||
|
'show_in_rest' => true,
|
||||||
|
);
|
||||||
|
|
||||||
|
register_post_type('property', $args);
|
||||||
|
}
|
||||||
|
add_action('init', 'homeproz_register_property_cpt');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flush rewrite rules on theme activation
|
||||||
|
*/
|
||||||
|
function homeproz_rewrite_flush() {
|
||||||
|
homeproz_register_property_cpt();
|
||||||
|
homeproz_register_property_taxonomies();
|
||||||
|
flush_rewrite_rules();
|
||||||
|
}
|
||||||
|
add_action('after_switch_theme', 'homeproz_rewrite_flush');
|
||||||
Reference in New Issue
Block a user