Copy the codes below and follow the instructions.
FOR SPECIFIC CATEGORY
1. Install Category Featured Images plugin.
2. Add an image to your category post.
3. Create a file that named category-7.php ( NOTE : The “7” in category-7.php is the category ID of your specific category ).
4. Copy and paste the codes in your category-7.php and upload it into your genesis child theme. See codes below.
add_action( 'genesis_meta', 'custom_category_function' ); function custom_category_function() { add_action( 'genesis_after_header', 'category_page_banner', 0 ); } function category_page_banner() { global $wp_query; $category = get_query_var( 'cat' ); $current_cat = get_category ( $category ); $category_id = $current_cat->term_id; $category_term = get_term_by( 'id', $category_id, 'category' ); $category_meta = $category_term->meta; echo '<article class="banner-section">'; echo '<img width="100%" src="'.cfi_featured_image_url( array( 'size' => 'full' ) ).'" class="category-image" alt="'.get_cat_name( $category_id ).'" />'; echo '<div class="banner-text">'; echo '<h6>'.strtoupper( $category_meta['headline'] ).'</h6>'; echo '<div class="intro-text">'.$category_meta['intro_text'].'</div>'; echo '</div>'; echo '</article>'; }
GENERAL CATEGORY LAYOUT
1. Install Category Featured Images plugin.
2. Add an image to your category post.
4. Create a file that named category.php.
5. Copy and paste the codes in your category.php and upload it into your genesis child theme. See codes below.
add_action( 'genesis_meta', 'custom_category_function' ); function custom_category_function() { add_action( 'genesis_after_header', 'category_page_banner', 0 ); } function category_page_banner() { global $wp_query; $category = get_query_var( 'cat' ); $current_cat = get_category ( $category ); $category_id = $current_cat->term_id; $category_term = get_term_by( 'id', $category_id, 'category' ); $category_meta = $category_term->meta; echo '<article class="banner-section">'; echo '<img width="100%" src="'.cfi_featured_image_url( array( 'size' => 'full' ) ).'" class="category-image" alt="'.get_cat_name( $category_id ).'" />'; echo '<div class="banner-text">'; echo '<h6>'.strtoupper( $category_meta['headline'] ).'</h6>'; echo '<div class="intro-text">'.$category_meta['intro_text'].'</div>'; echo '</div>'; echo '</article>'; }
Leave a Reply