Home > CMS Tutorial > WordPress > body text

How to automatically add content after the main text content in WordPress

angryTom
Release: 2019-11-16 11:59:54
Original
2678 people have browsed it

How to automatically add content after the main text content in WordPress

How does wordpress automatically add content after the text content

Many times, you need to add content after the article content Some information, such as subscriptions, article sharing, collections and Creative Commons license statements, etc.

If you want to automatically add content at the end of the article, you only need to add the code in the theme's function.php:

function insertFootNote($content) { 
    if(!is_feed() && !is_home()) { 
        $content.= "<div class=&#39;subscribe&#39;>"; 
        $content.= "<h4>Enjoyed this article?</h4>"; 
        $content.= "<p>Subscribe to our <a href=&#39;http://feed.php.cn/&#39;>RSS feed</a> and never miss a recipe!</p>"; 
        $content.= "</div>"; 
    } 
    return $content; 
} 
add_filter (&#39;the_content&#39;, &#39;insertFootNote&#39;);
Copy after login

The effect of the above example is that in each article A subscription reminder is automatically added at the end.

Recommended tutorial: WordPress tutorial

The above is the detailed content of How to automatically add content after the main text content in WordPress. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!