Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I try to insert a post with html tag with class attribute, like this: <dl class="dl-horizontal">, but after saving the post, WP removes an attribute.
How can I fix it?
The only way I've found, is to make a shortcode:

add_shortcode('attr', 'html_attr');
function html_attr( $atts, $content = null ){
 extract( shortcode_atts( array(
    'tag' =>"",
    'attr'=>""
  ), $atts ) );   
  return "<" .  $tag . " " . $attr . " >";
}

But I don't think that it's a right way...

share|improve this question
    
I can't duplicate this issue. The class attribute is not removed when I try it. Maybe you have a plugin conflict or your theme is doing something odd. –  s_ha_dum Dec 7 '12 at 14:33
    
@s_ha_dum, I think that it deppends on wich tag we are talking about. I also see that in span and div tag I can insert class and WP does not remove it. But in dl tag WP removes attributes. –  s976 Dec 8 '12 at 16:26
    
I thought about that and I tried it with the <dl> tag since that is the one you are using. It doesn't get stripped when I do it. –  s_ha_dum Dec 8 '12 at 16:35
add comment

2 Answers

Please look at the TinyMCE Advanced plugin.

http://wordpress.org/extend/plugins/tinymce-advanced/

You can configure it to leave certain tags alone. it's really useful.

share|improve this answer
add comment

Make sure you stay in the HTML mode in the text editor. Sometimes going back in and making changes in the Visual mode can overwrite HTML elements.

share|improve this answer
    
for sure I am in HTM mode –  s976 Dec 7 '12 at 11:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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