' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; echo '' . "\n"; // If not, then display the Site Title and Site Description. } else { echo '

' . esc_attr( get_bloginfo( 'name' ) ) . '

'; echo '

' . esc_attr( get_bloginfo( 'description' ) ) . '

'; } } endif; /** * Returns true if a blog has more than 1 category. * * @since 1.0.0 * @return bool */ function biancaa_categorized_blog() { if ( false === ( $all_the_cool_cats = get_transient( 'biancaa_categories' ) ) ) { // Create an array of all the categories that are attached to posts. $all_the_cool_cats = get_categories( array( 'fields' => 'ids', 'hide_empty' => 1, // We only need to know if there is more than one category. 'number' => 2, ) ); // Count the number of categories that are attached to the posts. $all_the_cool_cats = count( $all_the_cool_cats ); set_transient( 'biancaa_categories', $all_the_cool_cats ); } if ( $all_the_cool_cats > 1 ) { // This blog has more than 1 category so biancaa_categorized_blog should return true. return true; } else { // This blog has only 1 category so biancaa_categorized_blog should return false. return false; } } /** * Flush out the transients used in biancaa_categorized_blog. * * @since 1.0.0 */ function biancaa_category_transient_flusher() { // Like, beat it. Dig? delete_transient( 'biancaa_categories' ); } add_action( 'edit_category', 'biancaa_category_transient_flusher' ); add_action( 'save_post', 'biancaa_category_transient_flusher' ); if ( ! function_exists( 'biancaa_post_thumbnail' ) ) : /** * Featured thumbnail. * * @since 1.0.0 */ function biancaa_post_thumbnail() { // Setup empty variable. $size = ''; // Get the layout setting. $layout = get_post_layout( get_queried_object_id() ); $global = get_theme_mod( 'theme_layout' ); // Check the layout. if ( '1c-narrow' === $layout || '1c-narrow' === $global ) { $size = 'biancaa-featured-big'; } elseif ( '1c' === $layout || '1c' === $global && ! is_archive() && ! is_search() ) { $size = 'biancaa-featured-full'; } else { $size = 'biancaa-featured'; } // Display the thumbnail along with the size. the_post_thumbnail( $size, array( 'alt' => esc_attr( get_the_title() ) ) ); } endif; if ( ! function_exists( 'biancaa_featured_content' ) ) : /** * Sets up the featured posts based on user selected tag. * * @since 1.0.0 */ function biancaa_featured_content() { global $post; // Bail if not on home page. if ( ! is_home() ) { return; } // Get the featured posts setting value. $tag = get_theme_mod( 'biancaa_featured_posts', 'featured' ); $count = get_theme_mod( 'biancaa_featured_posts_count', 5 ); // Check if the tag is not empty. if ( empty( $tag ) ) { return; } // Get any existing copy of our transient data. if ( false === ( $featured = get_transient( 'biancaa_featured_posts' ) ) ) { // It wasn't there, so regenerate the data and save the transient. // Posts query arguments. $args = array( 'post_type' => 'post', 'posts_per_page' => (int) $count, 'tag' => esc_attr( $tag ) ); // The post query $featured = get_posts( $args ); // Store the transient. set_transient( 'biancaa_featured_posts', $featured ); } // Check if the post(s) exist. if ( $featured ) : $html = ''; // End check. endif; // Restore original post data. wp_reset_postdata(); // Display the featured content. if ( ! empty( $html ) ) { echo $html; } } endif; /** * Flush out the transients used in biancaa_featured_content. * * @since 1.0.0 */ function biancaa_featured_content_transient_flusher() { delete_transient( 'biancaa_featured_posts' ); } add_action( 'save_post' , 'biancaa_featured_content_transient_flusher' ); add_action( 'customize_save', 'biancaa_featured_content_transient_flusher' ); if ( ! function_exists( 'biancaa_pre_get_posts' ) ) : /** * Exclude featured posts from the home page blog query. * * @since 1.0.0 */ function biancaa_pre_get_posts( $query ) { // Bail if not home or not main query. if ( ! $query->is_home() || ! $query->is_main_query() ) { return; } $page_on_front = get_option( 'page_on_front' ); // Bail if the blog page is not the front page. if ( ! empty( $page_on_front ) ) { return; } // Get the tag. $featured = get_theme_mod( 'biancaa_featured_posts', 'featured' ); // Bail if no featured posts. if ( ! $featured ) { return; } // Get the tag name. $exclude = get_term_by( 'name', $featured, 'post_tag' ); // Exclude the main query. if ( ! empty( $exclude ) ) { $query->set( 'tag__not_in', $exclude->term_id ); } } add_action( 'pre_get_posts', 'biancaa_pre_get_posts' ); endif; if ( ! function_exists( 'biancaa_featured_text' ) ) : /** * Sets up the featured text. * * @since 1.0.0 */ function biancaa_featured_text() { // Bail if not on home page. if ( ! is_home() ) { return; } // Get the featured text. $text = get_theme_mod( 'biancaa_featured_text' ); if ( $text ) { echo ''; } } endif; if ( ! function_exists( 'biancaa_related_posts' ) ) : /** * Related posts. * * @since 1.0.0 */ function biancaa_related_posts() { // Only display related posts on single post. if ( ! is_single() ) { return; } // Get the taxonomy terms of the current page for the specified taxonomy. $terms = wp_get_post_terms( get_the_ID(), 'category', array( 'fields' => 'ids' ) ); // Bail if term empty. if ( empty( $terms ) ) { return; } // Query arguments. $query = array( 'tax_query' => array( array( 'taxonomy' => 'category', 'field' => 'id', 'terms' => $terms, 'operator' => 'IN' ) ), 'posts_per_page' => 3, 'exclude' => get_the_ID(), 'post_type' => 'post', ); // Allow plugins/themes developer to filter the default query. $query = apply_filters( 'biancaa_related_posts_query', $query ); // Perform the query. $related = new WP_Query( $query ); if ( $related->have_posts() ) : $html = ''; endif; // Restore original Post Data. wp_reset_postdata(); if ( isset( $html ) ) { echo $html; } } endif; if ( ! function_exists( 'biancaa_post_author' ) ) : /** * Author post informations. * * @since 1.0.0 */ function biancaa_post_author() { // Bail if not on the single post. if ( ! is_single() ) { return; } // Bail if user hasn't fill the Biographical Info field. if ( ! get_the_author_meta( 'description' ) ) { return; } ?>