diff --git a/home.php b/home.php index 5411a2e..035e309 100644 --- a/home.php +++ b/home.php @@ -34,9 +34,8 @@ get_header(); - +
-
@@ -46,10 +45,14 @@ get_header(); -
+ - + diff --git a/inc/bootstrap-wp-gallery.php b/inc/bootstrap-wp-gallery.php deleted file mode 100644 index b650c79..0000000 --- a/inc/bootstrap-wp-gallery.php +++ /dev/null @@ -1,139 +0,0 @@ - 'ASC', - 'orderby' => 'menu_order ID', - 'id' => $post->ID, - 'itemtag' => '', - 'icontag' => '', - 'captiontag' => '', - 'columns' => 3, - 'size' => 'thumbnail', - 'include' => '', - 'exclude' => '', - 'link' => '', - ], $attr ) ); - $id = intval( $id ); - $columns = ( 12 % $columns == 0 ) ? $columns : 3; - $grid = sprintf( 'col-sm-%1$s col-lg-%1$s', 12 / $columns ); - if ( $order === 'RAND' ) { - $orderby = 'none'; - } - if ( ! empty( $include ) ) { - $_attachments = get_posts( [ 'include' => $include, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $order, - 'orderby' => $orderby - ] ); - $attachments = []; - foreach ( $_attachments as $key => $val ) { - $attachments[ $val->ID ] = $_attachments[ $key ]; - } - } elseif ( ! empty( $exclude ) ) { - $attachments = get_children( [ 'post_parent' => $id, - 'exclude' => $exclude, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $order, - 'orderby' => $orderby - ] ); - } else { - $attachments = get_children( [ 'post_parent' => $id, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $order, - 'orderby' => $orderby - ] ); - } - if ( empty( $attachments ) ) { - return ''; - } - if ( is_feed() ) { - $output = "\n"; - foreach ( $attachments as $att_id => $attachment ) { - $output .= wp_get_attachment_link( $att_id, $size, true ) . "\n"; - } - - return $output; - } - $unique = ( get_query_var( 'page' ) ) ? $instance . '-p' . get_query_var( 'page' ) : $instance; - $output = '' : ''; - $output .= ''; - - return $output; -} - -add_shortcode( 'gallery', 'shortcode_gallery' ); - -/** - * Add class="thumbnail img-thumbnail" to attachment items - * - * @param string $html markup. - * - * @return mixed - */ -function attachment_link_class( $html ) { - $html = str_replace( ' array( 'default' => __( 'Default', 'understrap' ), 'masonry' => __( 'Masonry', 'understrap' ), + 'grid' => __( 'Grid', 'understrap' ), ), 'priority' => '30', ) ) ); + + // Columns setup for grid posts. + /** + * Function and callback to check when grid is enabled. + * @return bool + */ + function is_grid_enabled () + { + return 'grid' == get_theme_mod( 'understrap_posts_index_style' ); + } + if ( is_grid_enabled() ) { + // How many columns to use each grid post + $wp_customize->add_setting( 'understrap_grid_post_columns', array( + 'default' => '6', + 'type' => 'theme_mod', + 'capability' => 'edit_theme_options', + 'transport' => 'refresh', + ) ); + + $wp_customize->add_control( + new WP_Customize_Control( + $wp_customize, + 'understrap_grid_post_columns', array( + 'label' => __( 'Grid Post Columns', 'understrap' ), + 'description' => __( "Choose how many columns to use in grid posts", 'understrap' ), + 'section' => 'understrap_theme_layout_options', + 'settings' => 'understrap_grid_post_columns', + 'type' => 'select', + 'choices' => array( + '6' => '6', + '4' => '4', + '3' => '3', + '2' => '2', + '1' => '1', + ), + 'default' => 6, + 'priority' => '30', + 'transport' => 'refresh', + ) + ) ); + + } + // hook to auto-hide/show depending the understrap_posts_index_style option + $wp_customize->get_control( 'understrap_grid_post_columns' )->active_callback = 'is_grid_enabled'; } } add_action( 'customize_register', 'understrap_theme_customize_register' ); diff --git a/loop-templates/content-grid.php b/loop-templates/content-grid.php new file mode 100644 index 0000000..4e2885e --- /dev/null +++ b/loop-templates/content-grid.php @@ -0,0 +1,44 @@ + + +
+ + +
+ +
id="post-"> + ID ), '_wp_attachment_image_alt', true ); ?> + <?php echo esc_html( $alt ); ?> + +
+ +
+

+ + + + + + + +
+ +
+ +
+ + +
+ + +
+