Well, you are here because you've purchased Hemma WordPress theme but you don't have "Rooms" to showcase but "Villas". Or you may want to change the "Event" Custom Post Type to "Activity, etc.
Perfect, let's get started!
This is a very important step because your changes will remain untouched during the theme updates, and you will not have to go through this lengthy process again. There you can add your custom code. Now, let's say you want to rename rooms to villas.First thing to do is check that "Hemma Custom Post Types" plugin is active:
if( class_exists( 'Hemma_Custom_Post_Types' ) ) {
Change "Room/Rooms" to "Villa/Villas" in CPTs
function hemma_change_post_types_name( $args, $post_type ) {
if ( 'room' === $post_type ) {
$args['rewrite']['slug'] = 'villa';
$args['singular_label'] = __( 'Villa', 'hemma' );
$args['labels']['name'] = _x( 'Villas', 'post type general name', 'hemma' );
$args['labels']['singular_name'] = _x( 'Villa', 'post type singular name', 'hemma' );
$args['labels']['menu_name'] = _x( 'Villas', 'admin menu', 'hemma' );
$args['labels']['name_admin_bar'] = _x( 'Villa', 'add new on admin bar', 'hemma-custom-post-types' );
$args['labels']['add_new'] = _x( 'Add New', 'deal', 'hemma' );
$args['labels']['add_new_item'] = __( 'Add New Villa', 'hemma' );
$args['labels']['new_item'] = __( 'New Villa', 'hemma' );
$args['labels']['edit_item'] = __( 'Edit Villa', 'hemma' );
$args['labels']['view_item'] = __( 'View Villa', 'hemma' );
$args['labels']['all_items'] = __( 'All Villas', 'hemma' );
$args['labels']['search_items'] = __( 'Search Villas', 'hemma' );
$args['labels']['parent_item_colon'] = __( 'Parent Villas:', 'hemma' );
$args['labels']['not_found'] = __( 'No Villas Found', 'hemma' );
$args['labels']['not_found_in_trash'] = __( 'No Villas Found in Trash', 'hemma' );
}
return $args;
}
add_filter( 'register_post_type_args', 'hemma_change_post_types_name', 10, 2 );
Change "Room/Rooms" to "Villa/Villas" taxonomy names
function hemma_change_taxonomies_name( $args, $taxonomy ) {
if ( 'roomcategory' === $taxonomy ) {
$args['rewrite']['slug'] = 'villa-category';
$args['label'] = __( 'Villa Category', 'hemma' );
$args['labels']['name'] = _x( 'Villa Categories', 'taxonomy general name', 'hemma' );
}
return $args;
}
add_filter( 'register_taxonomy_args', 'hemma_change_taxonomies_name', 10, 2 );
You can optionally update some text strings in the backend as well:
function hemma_update_text_strings( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Select the room category you want to filter or leave "None". If you can\'t see any option in the list that\'s because you haven\'t any room category yet.' :
$translated_text = __( 'Select the villa category you want to filter or leave "None". If you can\'t see any option in the list that\'s because you haven\'t any villa category yet.', 'hemma' );
break;
case 'Filter Rooms' :
$translated_text = __( 'Filter Villas', 'hemma' );
break;
return $translated_text;
}
add_filter( 'gettext', 'hemma_update_text_strings', 20, 3 );