How to Put Some Text in every Post Content on WordPress Automatically?

China☆狼群 提交于 2020-01-16 11:43:06

问题


I want that Every Post Must Include this in every Post Like Template. For Example:

My Post Title: Time Management Post Content: [So Friends, How is our Article of "Post-Title". Do You Like it? Don't Forget to Comment below if Any Queries. For More Article regarding "Post-Title" Subscribe Us.]

I want this to put in every post at the end of the Article Automatically. Please Help Me. If Anyone Knows it.


回答1:


add_filter( 'the_content', 'filter_the_content_in_the_main_loop' );

function filter_the_content_in_the_main_loop( $content ) {

    // Check if we're inside the main loop in a single post page.
    if ( is_single() && in_the_loop() && is_main_query() ) {

       return esc_html__("So Friends, How is our Article of ".get_the_title().". Do You Like it? Don't Forget to Comment below if Any Queries. For More Article regarding ".get_the_title()." Subscribe Us.").$content;
    }

    return $content;
}



回答2:


You can use the the_content hook. See the below link.

https://developer.wordpress.org/reference/hooks/the_content/




回答3:


Find your answer here, this will show by-default 3 recent posts to your default content. LINK



来源:https://stackoverflow.com/questions/59526719/how-to-put-some-text-in-every-post-content-on-wordpress-automatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!