Home › Forums › Calendar Products › Events Calendar PRO › Default event title
- This topic has 5 replies, 2 voices, and was last updated 10 years, 5 months ago by
Nico.
-
AuthorPosts
-
October 19, 2015 at 7:24 am #1015803
Luke
ParticipantHi 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.
October 19, 2015 at 4:19 pm #1016016Nico
MemberHi 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,
NicoOctober 20, 2015 at 2:13 am #1016140Luke
ParticipantHi 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.
October 20, 2015 at 3:32 pm #1016396Nico
MemberHey 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,
NicoOctober 29, 2015 at 3:14 am #1019666Luke
ParticipantThanks Nico, that worked great.
October 29, 2015 at 7:36 am #1019746Nico
MemberGlad 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 -
AuthorPosts
- The topic ‘Default event title’ is closed to new replies.
