Wordpress_文章尾部追加固定内容

在主题function.php追加代码

function add_origin_link_on_post_end($content) {
    if(!is_feed() && !is_home() && is_singular() && is_main_query()) {
    $title = get_the_title();
    $permalink = get_permalink();
    $custom_header_content = '<hr class="wp-block-separator" /><h4 style="text-align: center;"><span style="color: #993366;"><strong>扫描网页右侧二维码关注公众号,可获取最新文章资源更新</strong></span></h4><div class="wp-block-image" style="text-align: center;"><figure class="aligncenter"><img width="400" height="173" class="wp-image-383" src="http://www.mubolin.cn:9999/wp-content/uploads/2018/10/zhifu.jpg" alt="" /></figure></div><p class="has-text-align-center" style="text-align: center;"><span style="color: #0000ff;">制作耗时耗力,如果您喜欢网站内容可以打赏,万分感谢,金额随意!!</span></p>';

     //插入尾部的写法
    $content .= $custom_header_content;
    }
    return $content;
}

add_filter('the_content', 'add_origin_link_on_post_end');
Editing is enabled. Use the "Save changes" button below the editor to commit modifications to this file.