You are here:Home » genesis framework » Custom Page Template in Genesis Child Theme - Page Layouts

Custom Page Template in Genesis Child Theme - Page Layouts

Page template is one which are created in WordPress template when you publish a new page there is an option on the left hand side to select the page template. Few page templates are applied by default. for example if you create an home.php it will automatically be applied when Home Page of the site is loaded. similarly single.php is applied when a page is viewed. in this tutorial we will create a Home Page Template for our Genesis Child theme.


HOW TO CREATE GENESIS PAGE TEMPLATE :

Creating a page template for the Genesis Child Theme is same as we create in other frameworks or custom WordPress Template but a little few changes to call the header,footer and footer widgets.

Creating Custom Page template :

<?php
/*
Template Name: Template Name Here
*/
?>
you can see a new page template has been created. all the code that we will enter in this template will be applied on the page which will use this template.

at the end we will call a function from Genesis to call the rest of the page elements (title, header, menu, footer widgets, footer)

<?php genesis(); ?>
Complete code :
<?php
/*
template name: Template Name Here
*/
?>

<!-- Start Custom Loop -->

<!-- End Custom Loop -->

<?php genesis(); ?>

Force Layout for Page Template :

if you want a full width, sidebar content, content sidebar or any other Genesis Layout for a Page Template you can use the following filter to force the layout of the page.
add_filter('genesis_pre_get_option_site_layout', 'name_of_the_layout');
Replace the second perameter with the name of the layout

List of Genesis Layout for Page Template :

// Force Full Width Layout

'__genesis_return_full_width_content'

// Force Content-Sidebar Layout

'__genesis_return_content_sidebar'

// Force Sidebar-Content Layout

'__genesis_return_sidebar_content'

// Force Content-Sidebar-Sidebar Layout

'__genesis_return_content_sidebar_sidebar'

// Force Sidebar-Sidebar-Content Layout

'__genesis_return_sidebar_sidebar_content'

// Force Sidebar-Content-Sidebar Layout

'__genesis_return_sidebar_content_sidebar'

Creating Full Width Home Page in Genesis Child Theme :

<?php

// GENESIS HOMEPAGE TEMPLATE //


// FORCE FULL WIDTH LAYOUT
add_filter ( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

// Homepage CUSTOM LOOP
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'my_custom_loop' );
function my_custom_loop () {
?>
 <div id="main_container">
  <div id="single-post" class="entry-content">
  
  // Add WP Query or Custom Columns for Home page Here
  
  </div> <!-- end single post -->
 </div> <!-- end main container -->
<?php } ?>


<?php genesis(); ?>

0 comments:

Post a Comment