• Skip to content
  • Skip to primary sidebar
  • Skip to footer

wpkb.org

WordPress and Laravel Knowledge Base

  • Home
  • Archive

Genesis Framework

Code to Change Page Layout Using Genesis Framework

July 27, 2017 by Sebastian Widmann Leave a Comment

If you want to change the page layout for specific sites, you can use this code:

/** Force full width layout on single posts only*/
add_filter( 'genesis_pre_get_option_site_layout', 'customize_site_layout' );

function customize_site_layout( $opt ) {
    global $post; 

    if ( is_page(292) || ($post->post_parent == 292) ) {
        $opt = 'sidebar-content'; 
    } 

    return $opt;
}

This code changes the default page layout for the site with ID 292 and the child pages of the site with ID 292.

Possible layouts are:

  • content-sidebar
  • sidebar-content
  • content-sidebar-sidebar
  • sidebar-sidebar-content
  • sidebar-content-sidebar
  • full-width-content

Filed Under: Genesis Framework Tagged With: Layout, Page

Redirect to First Child Page Using Genesis Framework

July 27, 2017 by Sebastian Widmann Leave a Comment

If you have a parent page, that should redirect to the first child page, you may use this snippet.

Create a new file named “go_to_first_child_template.php” in your theme directory.

Add the following content to the new file:

<?php
/*
Template Name: Redirect to first child page
*/

$args = array(
    'child_of' => $post->ID,
    'sort_column' => 'menu_order'
    );

$child_pages = get_pages($args);

if ($child_pages) {
    $first_child_page = $child_pages[0];
    wp_redirect( get_permalink($first_child_page->ID) );
} else {
    // Fallback, if there is no child page
    genesis();
}

Now you have to select as page template for the desired parent page the Template “Redirect to first child page”. When somebody opens the URL of the parent page, the page template looks for possible childs and openes the first child page (use the order weight to modify child pages order). If there is a child page, WordPress redirects to the child page, otherwise, the parent page is shown (as fallback).

Filed Under: Genesis Framework, WordPress Core Tagged With: Child Page, Menu, Parent Page, Redirect

Remove Post Info Using Genesis Framework

July 16, 2017 by Sebastian Widmann Leave a Comment

To remove the Post Info (date and author), you can use this snippet:

remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );

Filed Under: Genesis Framework Tagged With: Post Info, Remove

  • Page 1
  • Page 2
  • Page 3
  • …
  • Page 23
  • Next Page »

Primary Sidebar

Knowledgebase Categories

  • Advanced Custom Fields
  • Cloud9
  • Codeanywhere
  • FacetWP
  • Genesis Framework
  • InfiniteWP
  • Laravel
  • Laravel Homestead
  • macOS
  • MySQL Server
  • Relevanssi
  • ScotchBox
  • Simple History
  • Timber
  • Uncategorized
  • Vagrant
  • WooCommerce
  • WordPress Core
  • YARPP

Footer

Recent KB Entries

  • Ignore Case When Using sortBy in Laravel
  • Allow Empty Values when Validating URL or Email in Laravel
  • Install Laravel 5.5 at Codeanywhere with PHP 7.1 and MySQL 5.7
  • Change Post Order to Order by Last Modified Posts
  • Add add-apt-repositor to Codeanywhere Container

Recent Comments

  • Laravel 5.5(Cloud9)の開発環境自動構築スクリプトに3つの機能を追加! | Minory on Install MySQL 5.7 at Cloud9 Workspace
  • Vic Dorfman on Reset FacetWP Filters
  • Joanna on Reset FacetWP Filters
  • Kristov on Remove Emoji Support
  • Sebastian Widmann on Use Bootstrap 4 (BETA) in Laravel 5.5

© 2018 Sebastian Widmann | Privacy Policy | Site Notice

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkRead more