Family Encyclopedia >> Electronics

How to add default content in your WordPress Post editor

Have you ever found yourself entering the same text in all your posts? People often do that, like ask people to subscribe to their feed, retweet the post, share it on Facebook, etc. You can always use a simple tag to add right after the content, or you can add that text as the default content in your WordPress post editor.

Simply open your WordPress theme functions.php file and paste the following code inside the PHP course tags.

add_filter ('default_content', 'my_editor_content'); function my_editor_content ($ content) $ content = "Si te gusta esta publicación, entonces considera retuitearla o compartirla en Facebook". devolver $ contenido; 

And it's done. Try creating a new post and you should see the new content there.

Update (January 24, 2013) - One of our users asked us how to add different content for different types of posts in the comments. The following code will show you how to add different default content in your WordPress post editor for each specific custom post type:

 add_filter ('default_content', 'my_editor_content', 10, 2); function my_editor_content ($ content, $ post) switch ($ post-> post_type) case 'sources': $ content = 'your content'; descanso; caso 'historias': $ contenido = 'tu contenido'; descanso; caso 'fotos': $ contenido = 'su contenido'; descanso; predeterminado: $ contenido = 'su contenido predeterminado'; descanso; devolver $ contenido; 

Source:Justin Tadlock