Use the same date-based permalink structure for all post types

You’ll need to add the year, month, and day portions to the post’s permalink in your post_link callback: $link = str_replace( “https://wordpress.stackexchange.com/” . $pto->rewrite[ ‘slug’ ] . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/” . get_the_time( ‘Y/m/d’, $post ) . “https://wordpress.stackexchange.com/”, $link ); This will return a permalink such as example.com/2014/07/02/post-name. You’ll have to adjust the logic in your pre_get_posts … Read more

How to filter by date & a specific custom post type post-WP 4.4?

There is no logical explanation why if( is_post_type_archive(‘news) && is_date()) should fail and not work in your situation. is_date() return true on all date archives is_post_type_archive( ‘news’ ) will return true on post type archives When you visit localhost/2016/02/?post_type=news, both of those ring true, and they will only ring true on that specific URL If … Read more

Set meta field to publish date + 2 weeks

Try this: add_action(‘publish_post’, ‘dp_expiry’); function dp_expiry( $data ) { /*adds 2 weeks onto the current date in unix epoch format*/ $dp_new_expiry_date = (strtotime( current_time( ‘mysql’ ) ) + 1209600); /*converts unix timstamp back to yyyy-mm-dd format like you required*/ $dp_new_expiry_date_conv = date(“Y-m-d”, $dp_new_expiry_date); update_post_meta( $data[‘post_id’], ‘postexpiry’, $dp_new_expiry_date_conv ); }