Custom Category images Grid Template in Genesis

Add Custom post type category  images in grid template archive page. custom Page Template to show images set for categories in a grid on a static Page. categories-grid Format, in a all Category Archive pages





Category.php

<?php
/**
 * This file adds the category archive template.
 *
 */
//* Force full width content layout
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
//* Remove the breadcrumb navigation
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
//* Remove the post info function
remove_action( 'genesis_entry_header', 'genesis_post_info', 5 );
//* Remove the post content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
//* Remove the post image
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );



function categoryprefix_category_header() {
if ( is_category() )  {
echo '<h1 class="archive-title" style="text-align: center;">';
echo single_cat_title();
echo '</h1>';
}
}

add_action( 'genesis_before_loop' , 'categoryprefix_category_header' );


//* Add portfolio body class to the head
// add_filter( 'body_class', 'executive_add_portfolio_body_class' );
function executive_add_portfolio_body_class( $classes ) {
   $classes[] = 'executive-pro-portfolio';
   return $classes;
}
/**
 * Display as Columns
 *
 */


function be_category_post_class( $classes ) {

$columns = 4; // Set the number of columns here
$column_classes = array( '', '', 'one-half', 'one-third', 'one-fourth', 'one-fifth', 'one-sixth' );
$classes[] = $column_classes[$columns];
global $wp_query;
if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % $columns )
$classes[] = 'first';
return $classes;
}
add_filter( 'post_class', 'be_category_post_class' );
//* Add the featured image after post title
//add_action( 'genesis_entry_header', 'sk_category_grid' );
function sk_category_grid() {
    if ( $image = genesis_get_image( 'format=url&size=category-image' ) ) {
        printf( '<div class="category-grid-post-featured-image"><a href="%s" rel="bookmark"><img src="%s" alt="%s" /></a></div>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
    }
}
//* Customize entry meta in the entry header
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter($post_info) {
// $post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
$post_info = '[post_date] [post_edit]';
return $post_info;
}
//* Remove the post meta function
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
genesis();





 functions.php

//* Add new image size
add_image_size( 'category-image', 350, 263, true );

//* Display left floating featured image on single Posts
add_action( 'genesis_entry_content', 'show_featured_image', 9 );
function show_featured_image() {

if (is_singular( 'post' ))
genesis_image( array( 'size' => 'medium', 'attr' => array ('class' => 'alignleft') ) );

}

No comments:

Post a Comment

how to call ssh from vs code

 To call SSH from VS Code, you can use the built-in Remote Development extension. This extension allows you to open a remote folder or works...