diff --git a/functions.php b/functions.php index 1cd5296..dbad2fa 100644 --- a/functions.php +++ b/functions.php @@ -66,3 +66,8 @@ require get_template_directory() . '/inc/bootstrap-wp-gallery.php'; * Load WooCommerce functions. */ require get_template_directory() . '/inc/woocommerce.php'; + +/** + * Load a utilities library. + */ +require get_template_directory() . '/inc/utilities.php'; diff --git a/home.php b/home.php new file mode 100644 index 0000000..aebd111 --- /dev/null +++ b/home.php @@ -0,0 +1,80 @@ + + + + +
+ +
+ +
+ + + + +
+ +
+ + + + + + + + + + + + + + + + + + +
+ + +
+ + + + + + + + +
+ +
+ + + + diff --git a/inc/customizer.php b/inc/customizer.php index 7d809c0..2e1722e 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -123,6 +123,29 @@ if ( ! function_exists( 'understrap_theme_customize_register' ) ) { ) ) ); + // How to display posts index page (home.php) + $wp_customize->add_setting( 'understrap_posts_index_style', array( + 'default' => 'default', + 'type' => 'theme_mod', + 'capability' => 'edit_theme_options', + ) ); + + $wp_customize->add_control( + new WP_Customize_Control( + $wp_customize, + 'understrap_posts_index_style', array( + 'label' => __( 'Posts Index Style', 'understrap' ), + 'description' => __( "Choose how to display latest posts", 'understrap' ), + 'section' => 'understrap_theme_layout_options', + 'settings' => 'understrap_posts_index_style', + 'type' => 'select', + 'choices' => array( + 'default' => __( 'Default', 'understrap' ), + 'masonry' => __( 'Masonry', 'understrap' ), + ), + 'priority' => '30', + ) + ) ); } } add_action( 'customize_register', 'understrap_theme_customize_register' ); diff --git a/inc/utilities.php b/inc/utilities.php new file mode 100644 index 0000000..ece109d --- /dev/null +++ b/inc/utilities.php @@ -0,0 +1,32 @@ +post_content ); + + if ( str_word_count( $content, 0 ) > $word_count ) { + $words = str_word_count( $content, 2 ); + $keys = array_keys( $words ); + $excerpt = substr( $content, 0, $keys[ $word_count ] ); + $link_class = " class=\"btn btn-secondary understrap-read-more-link\""; + $excerpt = '

' . $excerpt . '[...]

'; + $excerpt .= '

Read More

'; + } else { + return $content; + } + + return $excerpt; +} + diff --git a/loop-templates/content-card.php b/loop-templates/content-card.php new file mode 100644 index 0000000..1973e6b --- /dev/null +++ b/loop-templates/content-card.php @@ -0,0 +1,49 @@ + +
+
id="post-"> + +
+ + ID ), '_wp_attachment_image_alt', true ); + ?> + <?php echo $alt; ?> + +
+ ', + esc_url( get_permalink() ) ), '' ); ?> + + + + + + +
+
+ +
+
+ ID, 15 ); + ?> + + '', + ) ); + ?> +
+ + +
+
+