Last active
July 13, 2018 21:55
-
-
Save danielpataki/87dda87e6160ac22bf27e2b8deb933a5 to your computer and use it in GitHub Desktop.
Custom post type templates
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
.site-content-contain { | |
position: static; | |
} | |
#review-head { | |
position: absolute; | |
top:55px; | |
left:0px; | |
padding:22px; | |
color:#fff; | |
width:100%; | |
text-align:center; | |
background: rgba(0,0,0,0.3); | |
} | |
#review-head h1 { | |
font-weight: 300; | |
margin:0px; | |
padding:0px; | |
} | |
#review-head small { | |
color: rgba(255,255,255,0.5); | |
font-weight: 500; | |
text-transform: uppercase; | |
font-size:11px; | |
letter-spacing: 1px | |
} |
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
<header id='review-head'> | |
<h1><?php the_title() ?></h1> | |
<small>Full Video Review</small> | |
</header> |
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
add_action( 'init', 'cptt_custom_post_types' ); | |
function cptt_custom_post_types() { | |
register_post_type( 'game', | |
array( | |
'labels' => array( | |
'name' => __( 'Games' ), | |
'singular_name' => __( 'Game' ) | |
), | |
'public' => true, | |
'has_archive' => true, | |
'supports' => array( 'title', 'editor', 'thumbnail' ), | |
'menu_icon' => 'dashicons-laptop' | |
) | |
); | |
} |
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( 'wp_enqueue_scripts', 'cptt_assets' ); | |
function cptt_assets() { | |
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' ); | |
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array( 'parent-style' )); | |
} |
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 get_template_part( 'template-parts/header/header', 'image' ); ?> |
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
/* | |
Theme Name: Custom Post Type Template Example | |
Theme URI: http://danielpataki.com | |
Description: An example theme that utilizes custom post type templates | |
Author: Daniel Pataki | |
Author URI: http://danielpataki.com | |
Template: twentyseventeen | |
Version: 1.0.0 | |
*/ |
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 | |
/* | |
Template Name: Game Review | |
Template Post Type: game | |
*/ | |
get_header( 'review' ); ?> | |
<div class="wrap"> | |
<div id="primary" class="content-area"> | |
<main id="main" class="site-main" role="main"> | |
<?php | |
/* Start the Loop */ | |
while ( have_posts() ) : the_post(); | |
get_template_part( 'template-parts/game/content', 'review' ); | |
// If comments are open or we have at least one comment, load up the comment template. | |
if ( comments_open() || get_comments_number() ) : | |
comments_template(); | |
endif; | |
the_post_navigation( array( | |
'prev_text' => '<span class="screen-reader-text">' . __( 'Previous Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Previous', 'twentyseventeen' ) . '</span> <span class="nav-title"><span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-left' ) ) . '</span>%title</span>', | |
'next_text' => '<span class="screen-reader-text">' . __( 'Next Post', 'twentyseventeen' ) . '</span><span aria-hidden="true" class="nav-subtitle">' . __( 'Next', 'twentyseventeen' ) . '</span> <span class="nav-title">%title<span class="nav-title-icon-wrapper">' . twentyseventeen_get_svg( array( 'icon' => 'arrow-right' ) ) . '</span></span>', | |
) ); | |
endwhile; // End of the loop. | |
?> | |
</main><!-- #main --> | |
</div><!-- #primary --> | |
<?php get_sidebar(); ?> | |
</div><!-- .wrap --> | |
<?php get_footer(); |
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 | |
/* | |
Template Name: Game Review | |
Template Post Type: game | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment