Replacing user text in post contents when rendered
What is the MOST correct way according to WP ideology to replace user text in the post content?
Example: I want to replace [b] User Text[/b]
To <strong> User text</strong>
when text rendered in the browser
Do I need filter? Do I need Short code API? Or it is perfectly fine to use PHP text replacing functions?
开发者_高级运维A small code sample will be highly appreciated.
I would use the Shortcode API, then your code for the functions.php would look something like this:
<?php
function shortcode_b_replace($atts, $content = null) {
return '<strong>'.$content.'</strong>';
}
add_shortcode("b", "shortcode_b_replace");
?>
精彩评论