I need to put HTML code directly in post. It works, except for some css attributes :

  • background-image
  • position

Every time a "editor" or "admin" user try to type those attributes in a style properties :

<div style="position:absolute">

The whole style properties is removed.

It works fine for the superadmin.

I tried to put this in my function.php :

remove_filter('content_save_pre', 'wp_filter_post_kses');
remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');

But it doesn't work.

I tried to edit roles, but the "unfiltered_html" capabilities seems to be deprecated, and anyway, checked for both admin and editor by default.

I know this filter is for security. But my site will be accessible to only one user, so I can't assume he won't try to hack his own site.

Thank you very much


I found a page explaining the problem, but without the solution : http://shinephp.com/is-unfiltered_html-capability-deprecated/

  • 2
    Can you explain your use case and need for this? If you're trying to embed things there may be better methods of doing this we can advise on
    – Tom J Nowell
    Commented Jan 28, 2014 at 22:05
  • It's just some page that need special design that cannot be achieved using a wysiwyg editor. So the html code is copied from Dreamviewer. It's not a blog.
    – Matthieu
    Commented Jan 29, 2014 at 9:03
  • Have you considered using a custom page template? Wether the post is a page or a blogpost is irrelevant ( all content is a post in WordPress )
    – Tom J Nowell
    Commented Jan 29, 2014 at 10:12
  • I know there is plenty way to achieve styling in Wordpress. But in this case, I need inline styling, and found it strange that Wordpress refuse it, althougth the two ways a tried are documented on Wordpress site, and should work.
    – Matthieu
    Commented Jan 29, 2014 at 17:34

1 Answer 1


Embedding a div container with an inline style attribute is not the way to do it. Your problem of WordPress stripping out certain attributes is a side effect of your real problem, not the problem itself.

  • You shouldn't be styling things inline, this isn't 1997, use CSS classes instead
  • You shouldn't need to put custom markup in a post

If you do need extensive custom markup that changes the layout or styling of a post/page, you should apply one of the following:

  • use a custom page template
  • implement a shortcode to wrap around the content, e.g.:

    [bluebox]This text is in a fancy blue box[/bluebox]

Disabling html filtering on non-admins doesn't solve your issue, it introduces new security issues, and makes your content hard to edit for the end user ( and yourself when you come back in a few months and have forgotten things ).

Finally, just because a wysiwyg editor generated the markup, doesn't mean it has to match it. If a more sensible way of implementing styling and html is available, rewrite it. Auto-generated code won't be the best way of writing webpages, and if your wysiwyg editor is giving you inline style attributes, then I wouldn't trust it.

  • I appreciate the time you spend for me, but I know all that.But it's a special case in which I need inline style. It's too long to explain why here, and it's not the point anywhere. My question is "how to remove wordpress filter" and not "how to style an element in wordpress".
    – Matthieu
    Commented Jan 29, 2014 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.