Skip to content

Instantly share code, notes, and snippets.

@jhned
Last active March 5, 2017 21:00
Show Gist options
  • Save jhned/db45d5e8c71cc80820f77bea1d5770c1 to your computer and use it in GitHub Desktop.
Save jhned/db45d5e8c71cc80820f77bea1d5770c1 to your computer and use it in GitHub Desktop.
How to do layout files
<?php
namespace CLIENT;
class Interior {
public static function init() {
add_action( 'wp', function () {
if ( ! is_front_page() ) {
self::hook_wordpress();
}
} );
}
public static function hook_wordpress() {
add_action( 'before_wrapper_div', [ __CLASS__, 'get_header_int' ], 20 );
add_action( 'after_content_div', [ __CLASS__, 'get_sidebar' ], 20 );
}
/**
* Gets the interior header if we're not on the home page.
*/
public static function get_header_int() {
get_template_part( 'partials/header-int' );
}
/**
* Gets the sidebar.
*/
public static function get_sidebar() {
get_sidebar();
}
}
Interior::init();
<?php
add_action( 'before_wrapper_div', 'client_get_header_int', 20 );
function client_get_header_int() {
if ( ! is_front_page() ) {
get_template_part( 'partials/header-int' );
}
}
add_action( 'after_content_div', 'client_interior_get_sidebar', 20 );
function client_interior_get_sidebar() {
if ( ! is_front_page() ) {
get_sidebar();
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment