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.

When we create a Image Gallery from the Media Modal Box and click on "Insert Gallery" button, the gallery shortcode is added to the main text area.

Is there a way to detect which Post Format is selected, and if its "Gallery" then is there a way to modify the action of the "Insert Gallery" button to add the shortcode to a meta box instead of the text area.

share|improve this question

1 Answer 1

That is a weird way to do it, shortcodes are really meant for inserting into the editor, if you want to program some functionality it's better to go straight into the template/code itself.

//check if post format is gallery type
if ( has_post_format( 'gallery' ) {
    echo do_shortcode('[gallery]');
}
share|improve this answer
    
I am actually trying to make this work for WordPress 3.6. Currently we need to first create a gallery which is then added to the Editor from where we have to copy paste it in the Gallery Meta Box. So I was trying to find a directly way to simply add some event to the "Insert gallery" button which could add the Gallery short code in the custom meta box. –  Harish Chouhan Mar 1 '13 at 20:08
    
The direct and better way is to do at at the template level, thus my answer. –  Wyck Mar 1 '13 at 22:05
    
We are still working on the post formats UI for 3.6, which as I keep reminding you, is in active development. There is no chance it will remain a bare field for the final release. If you'd like to donate your time to making this work in core, it would be greatly appreciated. –  helenhousandi Mar 2 '13 at 1:55
    
@helen, yes am aware of it, I just asked the question as I wanted to implement it in my current theme irrespective of whether it would be implemented in final WP 3.6. I have been able to create something basic but still lot of bugs. Once done will share it on WP trac –  Harish Chouhan Mar 7 '13 at 16:00

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.