WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 19 2011

How to Programatically Set the Default Page Layout

Like I mentioned on a previous post, do you worry that in their snooping they will change the default page layout to something other than the default on archive pages (ex: category).

[php]// Register default site layout option
genesis_set_default_layout( 'full-width-content' );[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 18 2011

How to Make the Top Section (above Sidebar/Content) Widgetized in the Genesis Framework

To make the area before the loop (or rather, the area before the sidebar/content area after the header) widgetized, add the following to your functions.php file:

[php]
genesis_register_sidebar( array(
'id' => 'genesis_before_content_sidebar_widget',
'name' => __( 'Before Content', 'genesis' ),
'description' => __( 'This is the main section after the header before the content/sidebar.', 'focus' ),
) );

add_action( 'genesis_before_content_sidebar_wrap', 'genesis_before_content_sidebar_widget_box' );
function genesis_before_content_sidebar_widget_box() {
if ( is_single() || is_home() || is_category || is_archive || is_page || is_front_page ) {
?>
<?php if ( is_active_sidebar( 'genesis_before_content_sidebar_widget' ) ) : ?>
<div class="before-content">
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('genesis_before_content_sidebar_widget') ) : ?>
<div class="widget">
<h3><?php _e( 'Top Widget Area', 'focus' ); ?></h3>
<p><?php _e("This is an example of a widget area that you can place text to describe a product or service. You can also use other WordPress widgets such as recent posts, recent comments, a tag cloud or more.", 'genesis'); ?></p>
</div><!-- end .widget -->
<?php endif; ?>
</div>
<?php endif; ?>
<?php
} }
[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 17 2011

How to Force a Specific Layout to Prevent User Error

Ever worry that your client will change or break your custom pages you built for them (e.g., homepage, 404 page, etc.)? Or, do you worry that in their snooping they will change the default page layout to something other than the default on archive pages (ex: category). The example below is to set the category and archive pages to Sidebar-Content-Sidebar and home page to Sidebar-Content.

[php]
// Force layout on category
add_filter('genesis_pre_get_option_site_layout', 'be_category_layout');
function be_category_layout($opt) {
if ( is_category() || is_archive() )
$opt = 'sidebar-content-sidebar';
return $opt;
}
// Force layout on home
add_filter('genesis_pre_get_option_site_layout', 'be_home_layout');
function be_home_layout($opt) {
if ( is_home() ) //May also be is_front_page()
$opt = 'sidebar-content';
return $opt;
}
[/php]

The available layout options are

  • Content/Sidebar = ‘content-sidebar’
  • Sidebar/Content = ‘sidebar-content’
  • Content/Sidebar/Sidebar = ‘content-sidebar-sidebar’
  • Sidebar/Sidebar/Content = ‘sidebar-sidebar-content’
  • Sidebar/Content/Sidebar = ‘sidebar-content-sidebar’
  • Full Width Content = ‘full-width-content’

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 16 2011

How to Make the Top-Level Menu Items Non-clickable in WordPress Custom Menus

Whether you use Genesis or not, one often question I see is: "How do I make the top-level items non-clickable?" And they go on to say that they are linked to a category, a landing page, a blank page, a random 404 page, etc. However, it is quite simple.

First, for Genesis users, ensure that you have selected Custom Menus in Genesis > Theme Settings. Then, navigate to the custom menus option via Appearance > Menus.

Second, create the custom links menu item by filling in the URL as "#" (without the quotes) inserting a label name, then clicking Add to Menu. Then locate it anywhere on the menu and click Save Menu.

DONE!

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 15 2011

Add Custom CSS File Based on Page Type: Front Page, Home Page, Category Page, Archive Page, 404 Page, Author Page, and Page

So I found one question that I read that asked how to have a custom CSS file per page. Here's an easy way to add custom CSS files based on simple conditional logic in Genesis.

[php]
remove_action('genesis_meta', 'genesis_load_stylesheet'); //removes current stylesheet
add_action('genesis_meta','genesis_custom_css');
//get_bloginfo('stylesheet_url') is our normal style.css
function genesis_custom_css() {
if (is_category())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/cat_style.css" type="text/css" media="screen" />'."n";
if (is_home() || is_front_page())
echo '<link rel="stylesheet" href="'.get_bloginfo('stylesheet_url').'" type="text/css" media="screen" />'."n";
if (is_archive())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/arch_style.css" type="text/css" media="screen" />'."n";
if (is_author())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/auth_style.css" type="text/css" media="screen" />'."n";
if (is_page()) //also can take $pages=array(1,2,3); adding and elseif or else at the end.
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/page_style.css" type="text/css" media="screen" />'."n";
if (is_404())
echo '<link rel="stylesheet" href="'.CHILD_DIR.'/css/page_style.css" type="text/css" media="screen" />'."n";
}
[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

  • « Previous Page
  • 1
  • …
  • 9
  • 10
  • 11
  • 12
  • 13
  • …
  • 18
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in