Skip to content

Instantly share code, notes, and snippets.

@xafarali
xafarali / post_page_content.php
Created June 9, 2013 20:11
Post the page content in template via page id or slug
$pageID = 'page name or slug';
get_ID_by_slug($pageID );
// page id by slug
function get_ID_by_slug($page_slug) {
$page = get_page_by_path($page_slug);
if ($page) {
return $page->ID;
} else {
@xafarali
xafarali / custom body class.php
Created June 9, 2013 20:08
Custom Body class
// Body Class
function add_body_class( $classes )
{
global $is_iphone;
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
@xafarali
xafarali / parent_template.php
Created June 9, 2013 19:00
Wordpress template redirection for child pages. Adopt Parent template if its assigned.
// Custom Template Inheritance -----------------------------
function custom_template_override () {
if( is_page() ) {
global $post;
if( $post->post_parent ) {
$parent_page_template = get_post_meta($post->post_parent,'_wp_page_template',true);
$current_page_template = get_post_meta($post->ID, '_wp_page_template' , true );