admin管理员组文章数量:1024666
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 badges1 Answer
Reset to default 0smraj,
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;
}
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 badges1 Answer
Reset to default 0smraj,
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;
}
本文标签: Plugin to display text before a post
版权声明:本文标题:Plugin to display text before a post 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745610278a2158963.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论