Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code used to register a 'podcast' CPT for officehours.fm. View CPT archive at https://officehours.fm/podcast/. Note that there's no loop customization. The archive page uses some hooks to move or remove certain elements and the "grid layout" is achieved via CSS (flexbox).
<?php
// Force full-width-content layout.
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );
// Move post info.
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
add_action( 'genesis_entry_footer', 'genesis_post_info' );
// Remove post content
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
// Move post image
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_entry_header', 'podcaster_do_grid_image', 8 );
genesis();
<?php
// I recommend using Bill Erickson's Core Functioanlity Plugin for registering post types (https://github.com/billerickson/Core-Functionality)
add_action( 'init', 'cd_register_post_type' );
/**
* Create site post types
* @since 1.0.0
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function cd_register_post_type() {
// Podcast custom post type
register_post_type( 'podcast',
array(
'labels' => array(
'name' => __( 'Podcast' ),
'singular_name' => __( 'Podcast' ),
),
'exclude_from_search' => false,
'has_archive' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-video-alt3',
'public' => true,
'rewrite' => array( 'slug' => 'podcast' ),
// Note the support added for 'genesis-cpt-archives-settings'. If you're using a plugin to register a CPT that doesn't already have support
// added for this then you can still add it via 'add_post_type_support' (https://codex.wordpress.org/Function_Reference/add_post_type_support).
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', 'genesis-cpt-archives-settings' ),
)
);
}
/* Archives
--------------------------------------------- */
.archive .content,
.home .content {
display: -webkit-box;
display: -moz-box;
display: box;
display: -webkit-flex;
display: -moz-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-lines: multiple;
-moz-box-lines: multiple;
box-lines: multiple;
-webkit-flex-wrap: wrap;
-moz-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: justify;
-moz-box-pack: justify;
box-pack: justify;
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
-ms-flex-pack: justify;
}
.archive article,
.home article,
.blog article {
-webkit-flex-basis: 20em;
-moz-flex-basis: 20em;
flex-basis: 20em;
-ms-flex-preferred-size: 20em;
-webkit-flex-grow: 1;
-moz-flex-grow: 1;
flex-grow: 1;
-ms-flex-positive: 1;
margin: 0 10px 20px 0;
position: relative;
}
.archive article .entry-header,
.home article .entry-header,
.blog article .entry-header {
font-weight: bold;
line-height: 1.5em;
overflow: hidden;
position: relative;
}
.archive article img,
.home article img,
.blog article img {
border-radius: 0;
float: none;
margin-bottom: 0;
max-width: 100%;
}
.archive article .entry-image-link:after,
.home article .entry-image-link:after,
.blog article .entry-image-link:after {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
opacity: .9;
}
.archive article.course .entry-image-link:after,
.home article.course .entry-image-link:after,
.blog article.course .entry-image-link:after {
display: none;
}
.archive article .entry-title,
.home article .entry-title,
.blog article .entry-title {
background: rgba(9, 105, 144, 0.5);
color: #fff;
font-size: 1.3em;
margin: 0;
padding: 5px 20px;
position: absolute;
top: 0;
}
.archive article .entry-title:hover,
.home article .entry-title:hover,
.blog article .entry-title:hover {
background: rgba(136, 170, 49, 0.5);
}
.archive article .entry-title a,
.home article .entry-title a,
.blog article .entry-title a {
color: #fff;
}
.archive article .entry-title a:hover,
.home article .entry-title a:hover,
.blog article .entry-title a:hover {
color: #fff;
}
.archive article .entry-content,
.home article .entry-content,
.blog article .entry-content {
font-size: 0.9em;
line-height: 1.5em;
}
.archive article .entry-image-link,
.home article .entry-image-link,
.blog article .entry-image-link {
position: relative;
overflow: hidden;
}
.archive article .overlay-image,
.home article .overlay-image,
.blog article .overlay-image {
bottom: 0;
left: 0;
right: 0;
opacity: .2;
position: absolute;
}
@media screen and (min-width: 1023px) {
.archive .search-form {
margin: 0 auto;
width: 30%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment