Filter

Kode remove_filter & add_filter di Functions WordPress

Fungsi remove_filter dan add_filter berikut akan menghapus fungsi standar yang ada pada filter core WordPress. Misalnya untuk menghilangkan kode <p> yang otomatis membentuk paragraf di single post, terapkan kode remove_filter('the_content', 'wpautop'); di functions.php. Baca juga fungsi remove_action di Functions WordPress

Pada Halaman Full Content

remove_filter('the_content', 'wpautop'); //menghilangkan kode <p> di konten single post

remove_filter('the_content', 'wptexturize'); //This returns given text with transformations of quotes to smart quotes, apostrophes, dashes, ellipses, the trademark symbol, and the multiplication symbol. Text enclosed in the tags 

<pre>, <code>, <kbd>, <style>, <script>, <tt>, and [code] will be skipped.

remove_filter('the_content', 'convert_chars'); //Metadata tags <title> and <category> are removed,  and <hr /> are converted into correct XHTML and Unicode characters are converted to the valid range. 

remove_filter('the_content', 'convert_smilies'); //Will only convert smilies if the option 'use_smilies' is true and the globals used in the function aren't empty.
Pada Halaman Excerpt
remove_filter('the_excerpt', 'wpautop');
remove_filter('the_excerpt', 'wptexturize');
remove_filter('the_excerpt', 'convert_chars');
remove_filter('the_excerpt', 'convert_smilies');
Pada Halaman Comment Fungsi berikut misalnya untuk menghilangkan link pada kolom komentar
remove_filter('comment_text', 'make_clickable', 9); //Disable link di kolom komentar WP
add_filter('comment_text', 'wp_filter_nohtml_kses'); //Disable html tags in comment
add_filter('comment_text_rss', 'wp_filter_nohtml_kses'); //Disable html tags in comment RSS
add_filter('comment_excerpt', 'wp_filter_nohtml_kses'); //Disable html tags in comment excerpt

Leave a Reply

*

*