As as title, how to prevent wp not to encode html in a post?
currently i just need to prevent ‘&’ change to ‘&
‘
The result need to be looks like on editor with html tab mode selected.
$content = $wpdb->get_row("SELECT post_content FROM $wpdb->posts WHERE ID=xxx");
$content = str_replace('amp;','',$content->post_content);//remove amp;
$wpdb->query("UPDATE $wpdb->posts SET post_content = $content WHERE ID = xxx;");
but that code still encode the html.
update:
and also how to implement content filter(prevent to encode some text) in collaboration with wp_insert_post()
function
update[SOLVED]: stackexchange
$content = get_post_field('post_content', XXX, 'raw');
$content = str_replace('amp;', '', $content);
$wpdb->update( $wpdb->posts, array( 'post_content' => $content ), array( 'ID' => XXX ) );
This code will print HTML tags, and then decode HTML entities (like
&
to&
).Oh, and with
wp_insert_post()
, do:You can use the escape function as a shortcode:
like
[escape]<span>Hello!</span>[/escape]
in blog posts. Is this what you meant by content filter?