How to insert custom content after each post?

is easier to use and it is a versatile blogging platform and here we can customize and develop different themes and plugins and it works in dual manner. For layman one could use different customized plugins and add-ons and for geeks there is already the room for adding extra codes and then without using the add ns and plugins one could make behave I that way.

The functions.php file of theme works in various ways and one can provide enough customizations and additions to it so that many different and some critical functions can work in seamless ways. It is a must that one should do from cPanel while doing editing of any of theme files.

Some people use from WordPress front end that is WordPress admin and in this process they reach to the stage where with some sort of wrong doing entire website could be in jeopardy and become down from internet. If you want to place some permanent information after each post then you can do it with some custom codes pasted into functions.php files and that information surely will be visible at the end of each and every article.

How to insert custom content after each post?

When you go though any of wordpress posts you could find apart from the changing nature of articles which is different in each single posts there are many common attributes are thee inside single post and most of these are done through this following wordpress snippets through its functions.php files. Through functions.php file we could help and manage the static contents to be showed inside WordPress single content. Here is the snippets to be pasted at the end of functions.php file

// add custom post content
 function add_post_content($content) {
 if(!is_feed() && !is_home()) {
 $content .= '<p>This article is copyright &copy; '.date('Y').'&nbsp;'.bloginfo('name').'</p>';
 return $content;
 add_filter('the_content', 'add_post_content');


You might like:  Some technical limitations to SSL at the protocol level

What this code snippet will make is that it will show copyright information at the end of article and if you have modified version of related posts code with css then perhaps you will have to further modify this code other wise this works seamlessly. In my template there is the related posts code and for this the visibility of this function code is breaking and that is why I am still trying to find out the other way out but if you have some other theme then it can work fine.

The next code snippet is about how to enable and easily display the total number of post’s word count. This actually works nicely if you write lengthier article and you want to display to the readers that you have wrote some 1000 worded or more article. There is a code snippet to do this and let us do it now.

There is the caution while doing these code snippets is that you should do it at your own risk and if you are not confident enough then it is better not to do it and if you do it then make it the back up of the edited file of the theme so that when at any point of time anything worse happens then you can easily uploaded the previous best option to make your site live again.

How to count word in posts?

As always I advise you to do this from File Explorer through cPanel and before editing any of theme file first download the copy to your local computer and then do the editing online. In this function we will be learning about how to display the count of yours post’s word count and for this first open the functions.php file of yours currently activate theme. Go to the extreme end of functions.php file and then paste the following code snippet and save the file.

// count words in posts
 function word_count() {
 global $post;
 echo str_word_count($post->post_content);


You might like:  How to build Categories, Archives and Tags in a Drop down menu without a plugin for Twenty Twelve Theme in WordPress

This is the first stage of the code snippet where the first code is pasted into functions.php and then in the next stage we will be moving into the stage where we would like the total count of words of posts to be displayed and for this we would like to paste it somewhere so that it would be visible.

The pasted code is as follows

<p>This post contains a whopping <?php word_count(); ?> words.</p>

CodeSource: –

Now, let us do some customization. I always fond of Twenty Twelve theme and I you are using it then you would be using its child theme and then open the content.php of it and then move to the following line of content.php file.

<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>

As always before doing anything back up the file to local computer so that at any point of time yours code editing goes wrong and yours site down then just replace the backup copy with it.
Place the following code just after it.

<?php if ( is_singular() ) : ?>
 <p>This post contains a whopping <?php word_count(); ?> words.</p>

<?php endif; ?>


Save content.php file and then open single post file and then scroll down to the end of article and before author link and you will find that there will be written as ‘This post contains a whopping ….. words’. In the place of dots you will find the number of words that is used in the article.

The code is as follows. The code

<?php if ( is_singular() ) : ?>

<?php endif; ?>

Says that this information should be visible to single posts instead of front page or index pages and this means that when you browse the article inside you could see the information there.

You might like:  Article writing tips:2

These information puts in between those two lines will only be visible when you browse the website o single post pages and this means that the attached information will only be visible when you enter into the length of article and by using this code and placing anything such as advertisements to show it only at the single pages and this means that you can then allow your visitors to see specific ads when they enter into that page only.

What we learn from this article is that there are endless possibilities to use your wordpress site and knowledge and the way you manage yours expertise and the way you intended to go over it and from time to time you would see that only smaller form of code snippets hat makes each and every form of wordpress site most beautiful and there is of course no need for further add ons and plugins to make your site more exhausted with it.

There are endless possibilities like that at the end of this article we are able to show codes in single posts only with a little bit of code and subsequently we do find plenty of other avenues such as showing the date and the latest updated formats and so on and there is the vast depository of article in Google search and you can find it and then try to implement with yours themes and if all goes in good way then all these be at the end of it works nicely and that will make you feel as a developer.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *