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?


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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