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

  • Resolved candeeg

    (@candeeg)



    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?

    array(
    		'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 7 replies - 1 through 7 (of 7 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 Huguette Inc

    (@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.

    Thanks!

    Plugin Author Huguette Inc

    (@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:

    2019-02-02T01:01

    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!

    Maxime

    (@maximefulpin)

    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 😉

    Cheers

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

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.