/* =============================================================
CLEARANCE ITEMS — CPT, Taxonomy & ACF Gallery
Paste into your theme's functions.php
============================================================= */
/* -------------------------------------------------------------
1. REGISTER CUSTOM POST TYPE: Clearance Items
------------------------------------------------------------- */
add_action( 'init', 'clr_register_post_type' );
function clr_register_post_type() {
$labels = array(
'name' => 'Clearance Items',
'singular_name' => 'Clearance Item',
'menu_name' => 'Clearance Items',
'name_admin_bar' => 'Clearance Item',
'add_new' => 'Add New',
'add_new_item' => 'Add New Clearance Item',
'new_item' => 'New Clearance Item',
'edit_item' => 'Edit Clearance Item',
'view_item' => 'View Clearance Item',
'all_items' => 'All Clearance Items',
'search_items' => 'Search Clearance Items',
'not_found' => 'No clearance items found.',
'not_found_in_trash' => 'No clearance items found in Trash.',
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 21,
'menu_icon' => 'dashicons-tag',
'query_var' => true,
'rewrite' => array( 'slug' => 'clearance' ),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'supports' => array( 'title', 'thumbnail', 'excerpt', 'revisions' ),
'taxonomies' => array( 'clearance_category' ),
'show_in_rest' => true,
);
register_post_type( 'clearance', $args );
}
/* -------------------------------------------------------------
2. REGISTER TAXONOMY: Clearance Categories
------------------------------------------------------------- */
add_action( 'init', 'clr_register_taxonomy' );
function clr_register_taxonomy() {
$labels = array(
'name' => 'Clearance Categories',
'singular_name' => 'Clearance Category',
'search_items' => 'Search Clearance Categories',
'all_items' => 'All Clearance Categories',
'parent_item' => 'Parent Category',
'parent_item_colon' => 'Parent Category:',
'edit_item' => 'Edit Clearance Category',
'update_item' => 'Update Clearance Category',
'add_new_item' => 'Add New Clearance Category',
'new_item_name' => 'New Clearance Category Name',
'menu_name' => 'Clearance Categories',
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'clearance-category' ),
'show_in_rest' => true,
);
register_taxonomy( 'clearance_category', array( 'clearance' ), $args );
}
/* -------------------------------------------------------------
3. ACF FIELD GROUP: Clearance Gallery + Content Fields
------------------------------------------------------------- */
add_action( 'acf/init', 'clr_register_acf_fields' );
function clr_register_acf_fields() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
acf_add_local_field_group( array(
'key' => 'group_clearance_gallery',
'title' => 'Clearance Gallery',
'fields' => array(
array(
'key' => 'field_clearance_top_content',
'label' => 'Top Content',
'name' => 'top_content',
'type' => 'textarea',
'instructions' => 'Shown after the title and red bar, before the image gallery.',
'required' => 0,
'rows' => 4,
'new_lines' => 'wpautop',
),
array(
'key' => 'field_clearance_gallery_images',
'label' => 'Gallery Images',
'name' => 'clearance_gallery_images',
'type' => 'gallery',
'instructions' => 'Upload photos for this clearance item. Use the Caption field on each image for the item description/price — when the photo is removed, its caption goes with it.',
'required' => 0,
'min' => 0,
'max' => 0,
'insert' => 'append',
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => 'jpg, jpeg, png, webp, gif',
'preview_size' => 'medium',
'return_format' => 'array',
),
array(
'key' => 'field_clearance_bottom_content',
'label' => 'Bottom Content',
'name' => 'bottom_content',
'type' => 'textarea',
'instructions' => 'Shown after the image gallery.',
'required' => 0,
'rows' => 4,
'new_lines' => 'wpautop',
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'clearance',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
) );
}
/* -------------------------------------------------------------
4. ACF FIELD GROUP: Clearance Category Fields
------------------------------------------------------------- */
add_action( 'acf/init', 'clr_register_category_acf_fields' );
function clr_register_category_acf_fields() {
if ( ! function_exists( 'acf_add_local_field_group' ) ) {
return;
}
acf_add_local_field_group( array(
'key' => 'group_clearance_category_image',
'title' => 'Clearance Category Fields',
'fields' => array(
array(
'key' => 'field_clearance_category_image',
'label' => 'Category Image',
'name' => 'category_image',
'type' => 'image',
'instructions' => 'Upload a representative image for this category.',
'required' => 0,
'library' => 'all',
'min_width' => '',
'min_height' => '',
'min_size' => '',
'max_width' => '',
'max_height' => '',
'max_size' => '',
'mime_types' => 'jpg, jpeg, png, webp',
'preview_size' => 'medium',
'return_format' => 'array',
),
array(
'key' => 'field_clearance_category_image_caption',
'label' => 'Image Caption',
'name' => 'image_caption',
'type' => 'text',
'instructions' => 'Caption shown below this category\'s image when displayed as a card.',
'required' => 0,
),
array(
'key' => 'field_clearance_category_top_content',
'label' => 'Top Content',
'name' => 'top_content',
'type' => 'textarea',
'instructions' => 'Shown after the title and red bar, before the grid of categories or items.',
'required' => 0,
'rows' => 4,
'new_lines' => 'wpautop',
),
array(
'key' => 'field_clearance_category_bottom_content',
'label' => 'Bottom Content',
'name' => 'bottom_content',
'type' => 'textarea',
'instructions' => 'Shown after the grid of categories or items.',
'required' => 0,
'rows' => 4,
'new_lines' => 'wpautop',
),
),
'location' => array(
array(
array(
'param' => 'taxonomy',
'operator' => '==',
'value' => 'clearance_category',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'active' => true,
) );
}
/* -------------------------------------------------------------
5. Disable Elementor lightbox on Clearance single pages
------------------------------------------------------------- */
add_action( 'elementor/frontend/after_enqueue_scripts', function() {
if ( is_singular( 'clearance' ) ) {
wp_add_inline_script( 'elementor-frontend', '
jQuery( window ).on( "elementor/frontend/init", function() {
elementorFrontend.hooks.addFilter(
"frontend/handlers/media/lightbox",
function() { return false; }
);
});
' );
}
});
Shop Amish Furniture by Category | Weaver Furniture Sales
Skip to content