Title: Inserting code after each post in WordPress
Last modified: August 19, 2016

---

# Inserting code after each post in WordPress

 *  [gutterboy333](https://wordpress.org/support/users/gutterboy333/)
 * (@gutterboy333)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/inserting-code-after-each-post-in-wordpress/)
 * Hey guys….. I am wanting to insert some code after each post in WordPress… I 
   know you can do it after this for example, in single.php
 * `<?php the_content(); ?>`
 * However if I do that it puts it in the wrong place.. an example post is here:
   [http://www.hardwareblog.com/348/computer-hardware/top-10-gadget-gift-ideas-to-avoid-this-christmas/](http://www.hardwareblog.com/348/computer-hardware/top-10-gadget-gift-ideas-to-avoid-this-christmas/)—
   if I put it AFTER the code example above it will be placed AFTER the sociable&
   facebook links….. I want to put it BEFORE those, so it’s RIGHT AFTER the post.
 * I did some checking & testing.. this code here from post-template.php
 *     ```
       function the_content($more_link_text = null, $stripteaser = 0) {
               $content = get_the_content($more_link_text, $stripteaser);
               $content = apply_filters('the_content', $content);
               $content = str_replace(']]>', ']]>', $content);
               echo $content;
           }
       ```
   
 * It seems the facebook & sociable code is inserted into the output within the 
   apply_filters() function…. though I can’t work out where.
 * Any help on what I am trying to do?
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [EnglishMike](https://wordpress.org/support/users/stringfold/)
 * (@stringfold)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/inserting-code-after-each-post-in-wordpress/#post-1787323)
 * The buttons are probably being inserted using the:
 * `add_filter('the_content', ...)`
 * filter call either by the theme you are using or by a plugin you installed to
   embed the social buttons, which means that they will already be present in $content
   after the template calls “the_content()”.
 * To put your code before the buttons, you will have to create your own filter 
   function with a higher priority than the other filter, like this:
 * `add_filter('the_content', 'my_filter_function', 1)`
 * The default priority is 10 so any number below that should ensure your filter
   is called first.
 * Alternatively, you could use the Embedder plugin for both the social buttons 
   and your other embed code. You can set them both to auto-embed in whatever posts
   of pages you want, and set the order in which you want them to appear:
 * [http://wordpress.org/extend/plugins/embedder/](http://wordpress.org/extend/plugins/embedder/)
 * (If you are just making a minor tweak, then I would advise just creating your
   own filter function as I described, but if you think you might be doing more 
   embedding in future, the Embedder plugin might be worth a look.)
 *  Thread Starter [gutterboy333](https://wordpress.org/support/users/gutterboy333/)
 * (@gutterboy333)
 * [15 years, 5 months ago](https://wordpress.org/support/topic/inserting-code-after-each-post-in-wordpress/#post-1787403)
 * Thank you very much!! 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Inserting code after each post in WordPress’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [gutterboy333](https://wordpress.org/support/users/gutterboy333/)
 * Last activity: [15 years, 5 months ago](https://wordpress.org/support/topic/inserting-code-after-each-post-in-wordpress/#post-1787403)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
