Skip to content

Tag: tag

How to disable wordpress html filter for posts and pages?

In some versions of WordPress there is a filter that strips some tags from the html code. If you want to remove this filter just open wp-includes/kses.php and find this row:

function kses_init_filters() {
    // Normal filtering.
    add_filter('pre_comment_content', 'wp_filter_kses');
    add_filter('title_save_pre', 'wp_filter_kses');

    // Post filtering
    add_filter('content_save_pre', 'wp_filter_post_kses');
    add_filter('excerpt_save_pre', 'wp_filter_post_kses');
    add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
}

and comment out the rows that you need:

function kses_init_filters() {
    // Normal filtering.
    add_filter('pre_comment_content', 'wp_filter_kses');
    add_filter('title_save_pre', 'wp_filter_kses');

    // Post filtering
    //add_filter('content_save_pre', 'wp_filter_post_kses');
    add_filter('excerpt_save_pre', 'wp_filter_post_kses');
    //add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
}

Then if you save the post in html it’s OK, but if you switch to normal view and then go back to html view the tags could be stripped again. This hapens most likely from the MCE Editor and to resolve this issue you could install a plugin called TinyMCE Valid Elements or some similar plugin.

Problem with category slug renaming in WordPress

I had a problem. I couldn’t change the category slug in some of my categories. So I found the solution at:

http://wordpress.org/support/topic/category-slug-cant-be-updated

The problem comes from the fact that the tags and categories are stored in the same table in the database. And the tags also have slugs. So if there is already a tag with the slug that you want to put in the category you can’t do it until you delete the tag or change it’s slug.

You just need to go to the tags table in the admin panel and change the tag slug that’s making the problem.

WordPress Facebook like button plugin doesn’t show on category and tag pages

I’m using this one:

FaceBook Like Button Plugin for WordPress

by http://healyourchurchwebsite.com/2010/04/22/the-facebook-like-button-plugin-for-wordpress/

But there in one limitation. It doesn’t show the button on the category archive view and on the tag archive view pages. Probably in some cases it is good, but in others it’s better to show it.

So in order to do this go to the plugin files and open fblike_content_filter.php

On line 12 there is:

if(     (is_front_page() && $fblike_settings_show_on_front_page == 'true') ||
 (is_single() && $fblike_settings_show_on_single_post == 'true') ||
 (is_page() && $fblike_settings_show_on_single_page == 'true') )
 {

Add two more lines so it will become like this:

if(     (is_front_page() && $fblike_settings_show_on_front_page == 'true') ||
 (is_single() && $fblike_settings_show_on_single_post == 'true') ||
 (is_category() && $fblike_settings_show_on_front_page == 'true') ||
 (is_tag() && $fblike_settings_show_on_front_page == 'true') ||
 (is_page() && $fblike_settings_show_on_single_page == 'true') )
 {

Additional info on the WordPress conditional tags can be found here:
http://codex.wordpress.org/Conditional_Tags

How to allow more html tags in the wordpress comments?

Scenario: I am using the tinymcecomments plugin to give some formatting capabilities to commenters. Also oEmbed for Comments is nice one – when you put a link to youtube or vimeo it automatically embeds the video.
With the latest WP update I realised the span tag was removed from comments; colors attributes are filtered by the kses filter.