Default event title

Home Forums Calendar Products Events Calendar PRO Default event title

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1015803
    Luke
    Participant

    Hi I am trying to set a default title for all new events but can’t seem to get it working as I need.

    I have the following code to set the default title of all new posts, regardless of post type. So this works for posts and events, whereas I just need it to work for events.

    add_filter( 'default_title', 'my_editor_content' );
    
    function my_editor_content( $content ) {
    
    	$content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
    
    	return $content;
    }

    I tried the following but it didn’t work and I’m not sure where I went wrong as I think this should work.

    add_filter( 'default_title', 'my_editor_content' );
    
    function my_editor_content( $content ) {
    if( get_post_type() == 'tribe_events' ) {
    
    	$content = "This is some custom content I'm adding to the post editor because I hate re-typing it.";
    
    	return $content;
    }
    }

    Any assistance would be appreciated.

    #1016016
    Nico
    Member

    Hi there Luke,

    Thanks for reaching out to us on this. Hopefully there’s a nice snippet George crafted for this:

    https://gist.github.com/ggwicz/b8a6bceaba0edd9efa2a

    You can download the file and install it as a plugin or just copy the code over to your functions.php file

    Please give that a try and let me know,
    Best,
    Nico

    #1016140
    Luke
    Participant

    Hi Nico,

    Thanks for the reply.

    Unfortunately I don’t think that snippet achieves what I am looking to do.

    I need to set the default title of all new events created to some custom text. So when I create a new event I need the title to already be filled out.

    For example: http://justintadlock.com/archives/2009/04/05/how-to-preset-text-in-the-wordpress-post-editor

    I have the code that works on all post types, but I can’t figure out how to get it working only for events.

    #1016396
    Nico
    Member

    Hey Luke,

    Thanks for clarifying, I was completely miss-understanding your request here, sorry for that!

    Please give this snippet a try and let me know if it does the trick now:

    add_filter( 'default_title', 'events_default_title', 10, 2 );
    function events_default_title( $title , $post ) {
    if( $post->post_type == 'tribe_events' ) {
    $title = "Pre-set title for events";
    }
    return $title;
    }

    Cheers,
    Nico

    #1019666
    Luke
    Participant

    Thanks Nico, that worked great.

    #1019746
    Nico
    Member

    Glad to hear Luke 🙂 Sorry for the initial miss understanding!

    I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Default event title’ is closed to new replies.