__( 'Header Menu', 'bluesand' ), ) ); //Add support for custom background add_theme_support( 'custom-background' ); //Add support for custom header $args = array( 'height' => 100, 'width' => 960 ); add_theme_support( 'custom-header', $args ); //Add support for custom background add_theme_support( 'automatic-feed-links' ); //Add support for post thumbnails or featured images add_theme_support( 'post-thumbnails' ); /*Change default markup for comments, search & caption to HTML5*/ add_theme_support( 'html5', array( 'comment-list', 'comment-form', 'search-form', 'caption' ) ); add_theme_support( 'title-tag' ); } endif; //bluesand_setup add_action( 'after_setup_theme', 'bluesand_setup' ); /** * Register widget area. * * @since Bluesand 1.0 */ function bluesand_widgets_init() { register_sidebar( array( 'name' => __( 'Sidebar Widgets', 'bluesand' ), 'id' => 'sidebar-widgets', 'description' => __( 'Add widgets here to appear in your sidebar.', 'bluesand' ), ) ); register_sidebar( array( 'name' => __( 'Footer Widgets', 'bluesand' ), 'id' => 'footer-widgets', 'description' => __( 'Add widgets here to appear in your footer.', 'bluesand' ) ) ); } add_action( 'widgets_init', 'bluesand_widgets_init' ); if ( ! function_exists( 'bluesand_excerpt_more' ) ) : /** * Replaces '[...]', which comes after excerpts in searches. * * * @since Bluesand 1.0 * * @return string '... Continue Reading'. */ function bluesand_excerpt_more() { global $post; return '... Continue Reading'; } endif; add_filter( 'excerpt_more', 'bluesand_excerpt_more' ); /** * Creates search form to add to wp_nav_menu() in the header. * * @since Bluesand 1.0 * * return string Items wrap for wp_nav_menu(). */ function bluesand_nav_items_wrap() { $wrap = ''; return $wrap; } /** * Forces the value of a checkbox in the Customizer to be '' or 1. * * @since Bluesand 1.0 * * @param string $value Value of checkbox. * @return string Empty string or 1. */ function bluesand_sanitize_checkbox( $value ) { if ( '' == $value || 1 == $value ) { return $value; } else { $value = ''; return $value; } } /** * Adds Featured Image (with post title and excerpt) to the header of home page. * * since Bluesand 1.0 */ function bluesand_featured_post() { $cat_id = get_query_var('cat'); //category id $tag = get_query_var('tag'); //tag name //If user disabled featured post for home page, do nothing if ( is_home() && get_theme_mod( 'bluesand_remove_featured' ) == 1 ) { return; } //If user disabled featured post for category and tag pages, do nothing if ( ( is_category() || is_tag() ) && get_theme_mod( 'bluesand_remove_featured_term' ) == 1 ) { return; } /*if it's the first page of the home, category or tag page, show featured image in header*/ if ( ( is_home() || is_category() || is_tag() ) && !is_paged() ) { //decrease the number of words in excerpt function bluesand_excerpt_length( $length ) { return 24; } add_filter( 'excerpt_length', 'bluesand_excerpt_length', 999 ); //change the [...] string at the end of excerpt to ... function bluesand_featured_excerpt() { global $post; return '...'; } add_filter( 'excerpt_more', 'bluesand_featured_excerpt' ); //get the most recent post with post meta key b_feature_this $args_home = array( 'meta_key' => 'b_feature_this', 'orderby' => 'DESC', 'posts_per_page' => 1, 'post_status' => 'publish', 'post__not_in' => get_option( 'sticky_posts' ) ); $args_cat = array( 'meta_key' => 'b_feature_this', 'orderby' => 'DESC', 'posts_per_page' => 1, 'post_status' => 'publish', 'post__not_in' => get_option( 'sticky_posts' ), 'cat' => $cat_id ); $args_tag = array( 'meta_key' => 'b_feature_this', 'orderby' => 'DESC', 'posts_per_page' => 1, 'post_status' => 'publish', 'post__not_in' => get_option( 'sticky_posts' ), 'tag' => $tag ); //Get the correct query for home, category or tag page. Else, do nothing if ( is_home() ) : $query = new WP_Query( $args_home ); elseif ( is_category() ) : $query = new WP_Query( $args_cat ); elseif ( is_tag() ) : $query = new WP_Query( $args_tag ); else : return; endif; //Loop to get the image link, post permalink, title, and excerpt and display in header if ( $query->have_posts() ) { ?> have_posts //remove the filters so the original excerpt length and more string can be used remove_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); remove_filter( 'excerpt_more', 'featured_excerpt' ); } // if is_home } //bluesand_featured_post /** * Add html5 workaround to head tags for IE9 or below. * * @since Bluesand 1.0 */ function bluesand_html5_shim() { echo ''; } add_action('wp_head', 'bluesand_html5_shim'); /** * Customizer additions. * * @since Bluesand 1.0 */ require get_template_directory() . '/inc/customizer.php';