Replace word in Post
-
Hello all,
I tried to realize a plugin that would allow me to replace some words by others in the post. I created the DB contained the words to replace and the word to put instead, i created the function and all is working fine, BUT, I don’t find how to use it on BBPRESS.
My function is something like
echo replace_words($TextToBeTransform,$WordToReplace)
, and the function use the DB to see what is be put instead of the $WordToReplace. As I can see, the post are printed out from the post.php of the template we do use.
I got this:
<?php
$tset="A trial phrase.";
$WordToBeReplaced="trial";
?>
<div class="threadpost">
<div class="post">
<?php echo replace_words( $test,$WordToBeReplaced); post_text()?></div>
<div class="poststuff">
<?php printf( __('Posted %s ago'), bb_get_post_time() ); ?>
<?php post_ip_link(); ?> <?php post_edit_link(); ?>
<?php post_delete_link(); ?></div>
</div>
It print me exactly as I want the “A trial phrase” replace trial by “new” (from the DB).
The problem is that when I want to apply this to the text of the post, post_text(), it won’t work at all. I see that this post_text() is actually applying filters and others to the text, which my cause my function to fail (no error, it just don’t replace the words).
Could someone tell me where should I apply my own filter replace_words() for it to be taken into account?
Thank you very much.
- You must be logged in to reply to this topic.