Home  >  Article  >  CMS Tutorial  >  How to automatically add content after the main text content in WordPress

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

angryTom
angryTomOriginal
2019-11-16 11:59:542687browse

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

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!

Statement:
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