Support » Plugin: Post Expiration Date » Not working with Custom Post Type

  • I made a custom post type, but I don’t see the expiration option. What do I need to add to the “Supports” of the post type array to add this?

    		'labels' => array(
    			'name' => __('Cruises'),
    			'singular_name' => __('Cruise'),
    		'public' => true,
    		'rewrite' => array("slug" => "cruises"), 
    		'supports' => array('thumbnail','editor','title','custom-fields','excerpt',)

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • it seems to support only posts out of the box.

    to add the metabox to custom post types or pages you can add this to your functions.php:

    function mycustomposttype_add_expire_date_metabox() {
    	add_meta_box( 'hugu_ped_expire_date_metabox', __( 'Expiration Date', 'hugu'), 'hugu_ped_expire_date_metabox_callback', array( 'mycustomposttype', 'page' ), 'side', 'high' );
    add_action( 'add_meta_boxes', 'mycustomposttype_add_expire_date_metabox' );

    just replace “mycustomposttype” with your custom post type!

    Plugin Author huguetteinc


    Yes @tobyy that looks great. Thanks for stepping in.

    I haven’t specifically addressed custom posts but fixes like this work well with the the way the plugin is constructed.

    Thanks @toby and @hugetteinc.
    I used the fuction and now I have a box on the custom post “Expiration Date” but it doesn’t have a date picker and typing in a date has no effect.


    Plugin Author huguetteinc


    Right now the datetime picker is only working in Chrome/Opera. If you want to test in a different browser you can use a format that looks like this:


    YYYY-DD-MMTHH:MM with the “T” just being a separator.

    v1.2 will support all modern browsers is in code review now and will be released in a few days.

    That did it, thanks!



    Code above tested & approved. Great thank you lads šŸ™‚

    Definitely a great feature to add the expiration date on custom post type as a native feature in the next version.

    It would be awesome to set up the expiration date based on the value of post custom fields šŸ˜‰


    I thought i asked this already, but how can I add this to a WooCommerce product page?

    Great Job. Thanks a lot !

    I second this request. I just downloaded the plugin to use specifically on a custom post type.

    I will try to get this working via the function – but yes, out of the box support seems like it would be a great step forward šŸ™‚

    @theviewer1985 I also downloaded this to use with a CPT and date picker still does not function outside of chrome.

    • This reply was modified 3 years, 9 months ago by hecforce.

    In addition to the code provided above, we had to disable the date picker built in our theme (we use Divi by Elegant Themes.) They had us add the following code to our functions.php file:

    function wpdocs_dequeue_script() {
       wp_dequeue_script( 'et_pb_admin_date_addon_js' );
    add_action( 'admin_enqueue_scripts', 'wpdocs_dequeue_script', 100 );
Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Not working with Custom Post Type’ is closed to new replies.