Allow tags and attributes in post and pages content
I am trying to allow the "onclick" attribute on links as well as some html tags such as iframe to the content displayed in posts and pages.
In my theme's functions.php file, I tried
removing filters such as wpautop
function rm_wpautop($content) { global $post; // Get the keys and values of the custom fields: $rmwpautop = get_post_meta($post-ID, 'wpautop', true); // Remove the filter remove_filter('the_content', 'wpautop'); if ('false' === $rmwpautop) { } else { add_filter('the_content', 'wpautop'); } return $content; } // Hook into the Plugin API add_filter('the_content', 'rm_wpautop', 9);
adding tags
add_action( 'init', 'allow_contenteditable' ); function allow_contenteditable() { global $allowedposttags; $tags = array( 'iframe' ); $new_attributes = array( 'contenteditable' = array() ); foreach ( $tags as $tag ) { if ( isset( $allowedposttags[ $tag ] ) is_array( $allowedposttags[ $tag ] ) ) $allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes ); } }
without any success.
Topic allowedtags functions filters theme-development Wordpress
Category Web