最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Plugin to display text before a post

programmeradmin1浏览0评论

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

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

Share Improve this question asked Apr 9, 2019 at 6:10 smrajsmraj 32 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

smraj,

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;
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论