Last active
December 12, 2018 00:07
-
-
Save neilgee/2a08284c58d3c76753d1d0b5c0120ce5 to your computer and use it in GitHub Desktop.
Genesis Archive Settings for Custom Post Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Archive Template - archive-custom-post-type-name.php | |
add_filter( 'genesis_pre_get_option_content_archive','cpt_change_content' ); | |
function cpt_change_content() { | |
return 'full'; | |
} | |
add_filter( 'genesis_pre_get_option_content_archive_limit','cpt_change_content_limit' ); | |
function cpt_change_content_limit() { | |
return 28; | |
} | |
add_filter( 'genesis_pre_get_option_content_archive_thumbnail','cpt_change_image_presence' ); | |
function cpt_change_image_presence() { | |
return 1; | |
} | |
add_filter( 'genesis_pre_get_option_image_size','cpt_change_image_size' ); | |
function cpt_change_image_size() { | |
return 'thumbnail'; | |
} | |
add_filter( 'genesis_pre_get_option_image_alignment','cpt_change_image_align' ); | |
function cpt_change_image_align() { | |
return 'alignright'; | |
} | |
add_filter( 'genesis_pre_get_option_posts_nav','cpt_change_pagination' ); | |
function cpt_change_pagination() { | |
return 'prev-next'; | |
} | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action('genesis_before_loop','cpt_change_all'); | |
function cpt_change_all() { | |
if ( is_post_type_archive( 'testimonial' ) ) { | |
add_filter( 'genesis_pre_get_option_content_archive','cpt_change_content' ); | |
function cpt_change_content() { | |
return 'full'; | |
} | |
add_filter( 'genesis_pre_get_option_content_archive_limit','cpt_change_content_limit' ); | |
function cpt_change_content_limit() { | |
return 28; | |
} | |
add_filter( 'genesis_pre_get_option_content_archive_thumbnail','cpt_change_image_presence' ); | |
function cpt_change_image_presence() { | |
return 1; | |
} | |
add_filter( 'genesis_pre_get_option_image_size','cpt_change_image_size' ); | |
function cpt_change_image_size() { | |
return 'thumbnail'; | |
} | |
add_filter( 'genesis_pre_get_option_image_alignment','cpt_change_image_align' ); | |
function cpt_change_image_align() { | |
return 'alignright'; | |
} | |
add_filter( 'genesis_pre_get_option_posts_nav','cpt_change_pagination' ); | |
function cpt_change_pagination() { | |
return 'prev-next'; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Archive Template - archive-custom-post-type-name.php | |
// Use breadcrumbs | |
add_filter( 'genesis_pre_get_option_breadcrumb_archive','__return_true' ); | |
// Set layout to full-width | |
add_filter( 'genesis_pre_get_option_site_layout','__genesis_return_full_width_content' ); | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Archive Template - archive-custom-post-type-name.php | |
// Modify the length of post excerpts | |
add_filter( 'excerpt_length', 'themeprefix_excerpt_length', 999 ); | |
function themeprefix_excerpt_length( $length ) { | |
return 10; // pull first 10 words | |
} | |
// Set post display amount | |
add_action( 'pre_get_posts', 'set_posts_per_page_for_testimonials_cpt' ); | |
function set_posts_per_page_for_testimonials_cpt( $query ) { | |
if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'testimonial' ) ) { | |
$query->set( 'posts_per_page', '3' ); | |
} | |
} | |
genesis(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Content Archive Full or Excerpt | |
add_filter( 'genesis_pre_get_option_content_archive','cpt_change_content' ); | |
function cpt_change_content() { | |
if ( is_post_type_archive( 'testimonial' ) ) { // Add in your CPT | |
return 'full'; // Other values - 'excerpt' | |
} | |
} | |
// Content amount limited in characters to display | |
add_filter( 'genesis_pre_get_option_content_archive_limit','cpt_change_content_limit' ); | |
function cpt_change_content_limit() { | |
if ( is_post_type_archive( 'testimonial' ) ) { | |
return 28; // Runs in accordance with 'full' set on content archive - returns limited character count | |
} | |
} | |
// Show the featured image | |
add_filter( 'genesis_pre_get_option_content_archive_thumbnail','cpt_change_image_presence' ); | |
function cpt_change_image_presence() { | |
if ( is_post_type_archive( 'testimonial' ) ) { | |
return 1; // 1 = display it, 0 = omit it | |
} | |
} | |
// Size of the image | |
add_filter( 'genesis_pre_get_option_image_size','cpt_change_image_size' ); | |
function cpt_change_image_size() { | |
if ( is_post_type_archive( 'testimonial' ) ) { | |
return 'thumbnail'; // Other values are any set image sizes as well as thumbnail, medium and large | |
} | |
} | |
// Alignment of the image | |
add_filter( 'genesis_pre_get_option_image_alignment','cpt_change_image_align' ); | |
function cpt_change_image_align() { | |
if ( is_post_type_archive( 'testimonial' ) ) { | |
return 'alignright'; // Other values alignleft and none | |
} | |
} | |
// Pagination, numeric or text | |
add_filter( 'genesis_pre_get_option_posts_nav','cpt_change_pagination' ); | |
function cpt_change_pagination() { | |
if ( is_post_type_archive( 'testimonial' ) ) { | |
return 'prev-next'; // Other value is 'numeric' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment