Last active
July 21, 2020 23:15
-
-
Save rachelmccollin/0decce4b62dc7ed9d8cc515d4de2be63 to your computer and use it in GitHub Desktop.
Ultimate guide to WordPress page 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
<?php | |
/* | |
The include for displaying the loop in static pages. | |
*/ | |
if ( have_posts() ) while ( have_posts() ) : the_post(); ?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<?php if ( is_front_page() ) { ?> | |
<?php } else { ?> | |
<h2 class="entry-title"><?php the_title(); ?></h2> | |
<?php } ?> | |
<section class="entry-content"> | |
<?php the_content(); ?> | |
</section><!-- .entry-content --> | |
</article><!-- #post-## --> | |
<?php do_action( 'compass_comments' ); /* action hook for comments - pluggable so you can override it if you don't want comments displayed */?> | |
<?php endwhile; ?> |
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 | |
/** | |
* The template for displaying all pages. | |
*/ | |
get_header(); ?> | |
<?php | |
/* Run the page loop to output the page content. | |
*/ | |
get_template_part( 'loop', 'page' ); | |
?> | |
<?php get_sidebar(); ?> | |
<?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
.content { | |
width: 65%; | |
float: left; | |
} | |
.sidebar { | |
width: 32%; | |
float: right; | |
} | |
.page-template-template-page-full-width .content, | |
.page-template-template-page-full-width .sidebar { | |
width: 100%; | |
float: none; | |
clear: both; | |
} |
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: Full width page | |
* | |
* A custom page template without sidebar. | |
* | |
*/ | |
get_header(); ?> | |
<?php | |
/* Run the page loop to output the page content. | |
*/ | |
get_template_part( 'loop', 'page' ); | |
?> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment