Hey men..... I'm attempting to place some code after each publish in WordPress... I understand it can be done following this for instance, in single.php

<?php the_content(); ?>

If however I actually do it puts it within the wrong place.. a good example publish is here now: http://www.hardwareblog.com/348/computer-hardware/top-10-gadget-gift-ideas-to-avoid-this-christmas/ -- basically place it Following the code example above it will likely be placed Following the interpersonal &lifier facebook links..... I wish to place it BEFORE individuals, therefore it is Immediately After the publish.

Used to do some checking &lifier testing.. this code here from publish-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(']]>', ']]&gt;', $content);
    echo $content;

It appears the facebook &lifier interpersonal code is placed in to the output inside the apply_filters() function.... though I can not exercise where.

Any help on which I'm attempting to do?


Here's one particular filter around the content and also the function:

    function the_content_replacer($content) 
//global $post, $posts;
       //$content = str_replace(']]>', ']]&gt;', $content);

 $content .= "\n<div style=\"display:none;\">text here</div>"; 

//$content = preg_replace('/="http:\/\/cnn/i', 
// '="http://example.com?http://cnn', $content, -1); 
       return $content;
    add_filter('the_content', 'the_content_replacer', 1);
  1. a lot more good examples about this filter on http://wordpress.stackexchange.com ..........
  2. You can easily copy the bit of content within the file "functions.php" inside your theme and it'll work.
  3. You may also just drop it within the directory wordpress-content/mu-plug ins in case your run multisite therefore it creates all of the blogs inside your multisite atmosphere.
  4. the 3rd parameters determines the significance of when using the filter, see: http://wordpress.stackexchange.com/questions/2126/at-what-priority-does-add-filter-overwrite-core-functions

--> it is best to publish all WordPress questions in http://wordpress.stackexchange.com !!!

--> if you are using e.g.

$content .= "\n<div style=\"display:none;\">text here</div>";

it won't remove a closing paragraph tag (note the linebreak at the outset of the string)