Permalink with Starting Date injected automatically

Home Forums Calendar Products Events Calendar PRO Permalink with Starting Date injected automatically

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #935327
    Jacques
    Participant

    Hi guys,

    Just saw an other topic about that feature : here

    I needed the functionality myself so I came up with this :

    function please_update_slug( $data, $postarr ) {
    	if($data['post_type'] == 'tribe_events') {
    	    if ( !in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) {
    			$post_id = $postarr['ID'];
    		    $value = $_POST["EventStartDate"];
    		    $date = new DateTime($value);
    	        $data['post_name'] = sanitize_title( $data['post_title'] . '-' . $date->format('d-m-Y'));
    	    }
    	}
        return $data;
    }
    add_filter( 'wp_insert_post_data', 'please_update_slug', 99, 2 );
    

    Just place this in your function.php and each time you create / save an event, the permalink of your event will be [event title]-[event-start-date].

    Hope it helps someone.

    Peace.

    #935330
    Jacques
    Participant

    Sorry wrong forum.

    #935376
    Barry
    Member

    Thanks for sharing, Jacques and no problem about posting it in the EDD Tickets forum – I went ahead and moved it across to our PRO forum (since we keep general events stuff in there).

    Cheers!

    #935513
    Jacques
    Participant

    Thanks Barry.

    I created a small Gist for it : https://gist.github.com/jacquesletesson/def518c8b0e9a8c85fa1

    #940550
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Permalink with Starting Date injected automatically’ is closed to new replies.