arnabwahid / wordpress-bootstrap

Bootstrap in WordPress theme form - Bootstrap 3.3.1
1.49k stars 556 forks source link

BS2 Code [span2] in shortcodes.php #184

Closed thejimbirch closed 10 years ago

thejimbirch commented 10 years ago

Hey,

Looks like you missed this in the upgrade. The code for the Wordpress Gallery should be something like this:

function gallery_shortcode_tbs($attr) {
    global $post, $wp_locale;

    $output = "";

    $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
    $attachments = get_posts($args);
    if ($attachments) {
        $output = '<div class="row">';
        foreach ( $attachments as $attachment ) {

            $output .= '<div class="col-sm-3">';
                        $att_title = apply_filters( 'the_title' , $attachment->post_title );
                        $output .= wp_get_attachment_link( $attachment->ID , 'medium', false );
            $output .= '</div>';
        }
        $output .= '</div>';
    }

    return $output;
}
Clocktower commented 10 years ago

Any idea on how to just remove the shortcode update with an action? The custom gallery shortcode omits many of the options that come standard when setting up a gallery?

remove_shortcode('gallery', 'gallery_shortcode_tbs');

Seems to remove the gallery shortcode altogether.

AlexWebLab commented 10 years ago

Have you tried this?

remove_shortcode('gallery', 'gallery_shortcode_tbs');
add_shortcode('gallery', 'gallery_shortcode');
Clocktower commented 10 years ago

I had. It would be ideal if the theme functions were pluggable.

I ended up having to add them to the init hook:

if (!function_exists('remove_shortcodes')) { function remove_shortcodes() { remove_shortcode('gallery', 'gallery_shortcode_tbs'); add_shortcode('gallery', 'gallery_shortcode'); } } add_action('init', 'remove_shortcodes');

Thanks for takign the time.

thejimbirch commented 10 years ago

If you are using a child them with it's own library/shortcodes.php, you could probably just delete lines 7 - 30.

Clocktower commented 10 years ago

You are absolutely correct.

thejimbirch commented 10 years ago

Excellent!

chrisbarnes commented 10 years ago

I've pulled out the custom wp_bootstrap gallery shortcode in favor of sticking closer to what comes with WordPress out of the box.