admin管理员组

文章数量:1122846

I'm working on a project where I use WordPress admin hooked up with Laravel. I use WP to edit and create posts and Laravel to query the database. I also use shortcodes.

Is it possible to call the do_shortcode() function when saving post content so that the "compiled" version goes into the database and not the shortcode version?

I'm working on a project where I use WordPress admin hooked up with Laravel. I use WP to edit and create posts and Laravel to query the database. I also use shortcodes.

Is it possible to call the do_shortcode() function when saving post content so that the "compiled" version goes into the database and not the shortcode version?

Share Improve this question asked Apr 16, 2015 at 12:50 TamásTamás 1333 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

So I found my answer in the codex.

content_save_pre() is my friend. Here is the usage:

function my_sanitize_content( $content ) {
    return do_shortcode($content);
}
add_filter( 'content_save_pre' , 'my_sanitize_content' , 10, 1);

Haven't tried it yet, it should work I suppose.

本文标签: shortcodeSaving post content to database with doshortcode