I am trying to display some text before publising post.When i add post i am getting error as

Publishing failed

my code is

function adddata(){

echo "Welcome to my  post!..........";


add_action('new_to_publish', 'adddata');

It is not getting displayed



try to use a filter. Use this code snippet. Place this in our theme's functions.php file

add_filter('the_content', 'adddata');

function adddata($content) {

$pre_post_text = 'Welcome to my  post!..........';

// only display this on single post pages
if(is_single() && !is_home()) {
  $content = $pre_post_text.$content;
return $content;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.