WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Mar 24 2011

How to Switch Primary Sidebar to Secondary Sidebar for a Specific Page in Genesis

For one of my sites, the person wanted to use two different sidebars: one for his store and another for his blog. The rest of the site was full-width layout. So we used the two sidebars: Primary (sidebar) and Secondary (sidebar-alt). So here's how to switch sidebars (without using Nathan's phenomenal plugin Simple Sidebars) using functions.php.

[php]//switch sidebars
add_action('get_header','change_genesis_sidebar');
function change_genesis_sidebar() {
$pages = array(181);

if ( is_page($pages)) {
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' );
add_action( 'genesis_sidebar', 'genesis_do_sidebar_alt' );
}
} [/php]

This code can be easily adapted to be done based on category, archives, author, etc. See the conditional tags for more details.

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 23 2011

How to Customize Genesis's Search Form Text and Button Text

Customize the Search Form text
[php]add_filter('genesis_search_text', 'be_custom_search_text');
function be_custom_search_text($text) {
return esc_attr('Search');
}[/php]

Customize the Search Button text
[php]add_filter('genesis_search_button_text', 'be_custom_search_button_text');
function be_custom_search_button_text($text) {
return esc_attr('');
}[/php]

Written by Travis Smith · Categorized: Genesis, Tutorials

Mar 22 2011

Add a Genesis Authorbox Anywhere Using My Genesis Authorbox Shortcode

As I am slowly developing a new plugin, Genesis Simple Authorbox, I realized that I should just release parts to the community that I believe would be beneficial. Follow these simple steps to incorporate the Authorbox Shortcode.

  1. Download the Genesis Simple Authorbox Shortcode: [download id="6"]
  2. Upload it to your Child Theme folder
  3. Add the following PHP Code to your functions.php file:
    [php]require_once( CHILD_DIR.'/genesis-author-box-shortcode.php' );[/php]

Now you can use [genauthorbox] to produce the Genesis Authorbox anywhere you'd like. This is also perfect for Genesis Child Theme developers using do_shortcode().

Attributes

[genauthorbox] takes a few attributes. They are:

  • before: Text/markup to place before the authorbox; default: <div class="author-box">
  • after: Text/markup to place after the authorbox; default: </div>
  • context: Context of the authorbox; default: '' NOTE: don't use this unless you are comfortable with it
  • title: Title of the authorbox; default: "About First Last Name" (e.g., get_the_author())
  • description: The author description/Biographical Info from Your Profile; default: (empty)
  • gclass: Adds a class to the gravatar img; default: alignleft
  • galt: Adds ability to provide an Alt Tag to the gravatar img; default: (empty)
  • gsize: Adds ability to resize gravatar image; default: 70
  • gemail: Fetch gravatar image by email (only changes the avatar & does not change the author information [e.g., title, description]); default: get_the_author_meta('email')
  • userid: Overrides gemail, title, & description with the default user's (title: About First Last; description: biographical info; gemail: user's email); default: (empty)

Example

[genauthorbox title="About Mr. Starbucks" Description="I am a hopeless Starbucks addict, freelance web designer..." gsize=72 galt="not me" gemail="[email protected]"]

Written by Travis Smith · Categorized: Genesis, Plugins

Mar 22 2011

Useful WordPress, Genesis, & Thesis Directory and URL (HTTP) PHP Constants

When creating WordPress plugins, themes, or tweaking plugins, themes, functions.php, you will often need to reference files and folders throughout the WordPress installation. Since WordPress 2.6 (if they are pre-2.6, then use die();), users have had the ability to move this directory anywhere they want, so you always want to avoid hardcoding so that the code is re-usable, especially with plugins. WordPress has defined a set of PHP CONSTANTS (by the way, constants are always UPPERCASE) to store the path to the wp-content and plugins directories. You can use these CONSTANTS in your plugins, child themes or functions.php for any paths you need regardless of where the actual directory might exist on the server.

  • WP_CONTENT_URL: Full URL to wp-content
  • WP_CONTENT_DIR: The server path to the wp-content directory
  • WP_PLUGIN_URL: Full URL to the plugins directory
  • WP_PLUGIN_DIR: The server path to the plugins directory
  • WP_LANG_DIR: The server path to the language directory

You can set your own CONSTANT_DIR by (as a reminder, constants are always UPPERCASE):

[php]define('CONSTANT_DIR', ABSPATH . 'wp-content'); //sets DIR[/php]

You can set your own CONSTANT_URL by (as a reminder, constants are always UPPERCASE):

[php]define('CONSTANT_URL', get_option('siteurl').'/wp-content/'); //sets URL[/php]

For GENESIS Users, some CONSTANTS of interests are:

  • STYLESHEETPATH: /.../.../.../..../.../.../wp-content/themes/child_theme
  • TEMPLATEPATH: /.../.../.../..../.../.../wp-content/themes/genesis
  • PARENT_URL: get_bloginfo(‘template_directory’): e.g., http://domain.com/wp-content/themes/genesis
  • CHILD_URL: get_bloginfo(‘stylesheet_directory’): e.g., http://domain.com/wp-content/themes/child_theme
  • PARENT_THEME_VERSION: refers to the Genesis version running
  • PARENT_THEME_NAME = 'Genesis'
  • GENESIS_LANGUAGES_URL (sets to Genesis Library for Child Themes)

For THESIS (1.8) Users, some CONSTANTS of interests are:

  • THESIS_CUSTOM = STYLESHEETPATH: /.../.../.../..../.../.../wp-content/themes/thesis_18/custom
  • THESIS_CUSTOM_FOLDER: get_bloginfo('stylesheet_directory') . '/custom': e.g., http://domain.com/wp-content/themes/thesis_18/custom
  • THESIS_LAYOUT_CSS: THESIS_CUSTOM . '/layout.css: e.g., http://domain.com/wp-content/themes/thesis_18/layout.css
  • THESIS_ROTATOR:THESIS_CUSTOM . '/rotator': e.g., http://domain.com/wp-content/themes/thesis_18/rotator
  • THESIS_ROTATOR_FOLDER: THESIS_CUSTOM_FOLDER . '/rotator': e.g., http://domain.com/wp-content/themes/thesis_18/rotator

Are there any CONSTANTS that are used quite often that I missed?

Written by Travis Smith · Categorized: Genesis

Mar 21 2011

How to Create a WordPress Custom Post Type Template in Genesis

Custom post types can be rather confusing, daunting, intimidating, and frankly difficult. However, with Genesis, custom post types are easy as registering your post type, creating a template, and adding a page that uses the template. While I will assume that you know how to register your custom post type, if you don't download Brad William's/WebDevStudios' Custom Post Type UI Plugin.

To create your page template, you can simply download it here ([download id="5"]), or follow these instructions. In your favorite text editor, create a new document. Then add the following code:
[php]<?php
/*
*Template Name: Custom Post Type Template
*/

remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'custom_do_loop');
function custom_do_loop() {
global $paged;
$args = array('post_type' => 'my_post_type');
//$args = array('post_type' => 'books');

genesis_custom_loop( $args );
}
genesis();
?>[/php]
Template Name: Custom Post Type Template identifies it as a page template, so when you click Pages > Add New, your new template will appear in the right hand side for Page Templates as whatever you named it. To customize this template, change my_post_type to whatever you named your post type, which should be all lower case with no spaces. The default is 'post', which does not pick up your custom post type.

Written by Travis Smith · Categorized: Genesis, Tutorials

  • « Previous Page
  • 1
  • …
  • 14
  • 15
  • 16
  • 17
  • 18
  • …
  • 20
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

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