From 64c5ea25c22ead3f52e06e94562965abfb70ee12 Mon Sep 17 00:00:00 2001 From: Stef Kariotidis Date: Sun, 20 Nov 2016 13:09:16 +0200 Subject: [PATCH 1/3] blog page as grid --- home.php | 19 ++++++++------ inc/customizer.php | 1 + loop-templates/content-grid.php | 44 +++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 loop-templates/content-grid.php diff --git a/home.php b/home.php index 9f08b55..f258bc4 100644 --- a/home.php +++ b/home.php @@ -27,9 +27,8 @@ $posts_style = get_theme_mod( 'understrap_posts_index_style' ); - +
-
@@ -39,10 +38,14 @@ $posts_style = get_theme_mod( 'understrap_posts_index_style' ); -
+ - + diff --git a/inc/customizer.php b/inc/customizer.php index 2e1722e..67a167a 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -142,6 +142,7 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) { 'choices' => array( 'default' => __( 'Default', 'understrap' ), 'masonry' => __( 'Masonry', 'understrap' ), + 'grid' => __( 'Grid', 'understrap' ), ), 'priority' => '30', ) diff --git a/loop-templates/content-grid.php b/loop-templates/content-grid.php new file mode 100644 index 0000000..dbde89d --- /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 ); ?> + +
+ +
+

+ + + + + + + +
+ +
+ +
+ + +
+ + +
+
From 77ca414da60bd70fbd7be5da09ea19a83e83f40c Mon Sep 17 00:00:00 2001 From: Stef Kariotidis Date: Mon, 21 Nov 2016 11:54:27 +0200 Subject: [PATCH 2/3] add option for column settings --- inc/customizer.php | 44 +++++++++++++++++++++++++++++++++ loop-templates/content-grid.php | 5 ++-- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/inc/customizer.php b/inc/customizer.php index 67a167a..9e8b035 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -147,6 +147,50 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) { '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 index dbde89d..223e520 100644 --- a/loop-templates/content-grid.php +++ b/loop-templates/content-grid.php @@ -4,10 +4,11 @@ * * @package understrap */ - +$col = get_theme_mod( 'understrap_grid_post_columns' ); +error_log($col); ?> -