Genesis Quick Tips

There’s a lot of small code snippets I use often but don’t warrant their own post. This is where I’ll collect them. If you have any quick tips, feel free to share in the comments.

Also check my general code snippets page.

Setup the child theme
As described here, it’s a good idea to create a theme setup function in which you’ll place all the filters, actions, and theme-supported features. This is what I include at the top of my functions.php file in my child themes. Any time below you see an add_action or add_filter, that part goes in the setup function, and the function itself goes after the setup function.

Force a page layout
This is very useful for ensuring custom pages you build for a client aren’t broken by them changing the page layout (ex: home page). Or, changing the page layout to something other than the default on archive pages (ex: category).

Unregister unused page layouts

Structural Wrap
This adds a div with the class of “wrap” in an element. In the code below I’m adding it to #inner for a full-width page layout. More details.

Add Image Sizes
See Mark Jaquith’s postfor details. This adds an image size named ‘feature’ with a fixed size of 600×250.

add_image_size('feature', 600, 250, true);

Remove Post Info

remove_action('genesis_before_post_content', 'genesis_post_info');

Modify Post Info
Shortcode Reference

Remove Post Meta

remove_action('genesis_after_post_content', 'genesis_post_meta');

Modify Post Meta

Change Excerpt More text […]

Remove Footer

remove_action('genesis_footer','genesis_do_footer');

Remove Footer and Footer Markup

(thanks Paul de Wouters)

Customize the Search Form text

Customize the Search Button text

Remove Breadcrumbs

remove_action('genesis_before_loop', 'genesis_do_breadcrumbs');

Remove Home from Breadcrumbs
add_filter('genesis_home_crumb', '__return_false');

Customize the Breadcrumb
Full list of arguments here.

Customize the Site Title (in #header)
This is useful if you want to use the default site title (Settings > Title) but style different elements of it differently. This specific code searches for “of” in the site title, and changes it to <em>of</em>.

Remove the Post Title

remove_action('genesis_post_title','genesis_do_post_title');

Display Description of Menu Items
To add a description to a menu item, go to Appearances > Menus. At the top right click “Screen Options”, then check “Description”. Now you can click the dropdown arrow next to menu items and add a description. The below code will make it visible on the site. Here’s another, more detailed approach.

Register a Sidebar

Unregister a Sidebar

unregister_sidebar('sidebar-alt');

Customize Read More Link

CSS – Images scale to content area (useful for Responsive Design)

Bill Erickson

Bill Erickson is the co-founder and lead developer at CultivateWP, a WordPress agency focusing on high performance sites for web publishers.

About Me
Ready to upgrade your website?

I build custom WordPress websites that look great and are easy to manage.

Let's Talk

Reader Interactions

Comments are closed. Continue the conversation with me on Twitter: @billerickson

Comments

      • Bill Erickson says

        I’m not sure what you mean. Can you expand upon it?

        If you’re looking to put the year in the footer (ex © 2011) and want it to auto update, use [footer_copyright]

  1. djmaki says

    Hey!

    Do you know, how to ad the post title in the footer?
    No matter if is a article site or home, or category/blog section.
    I want to show the title of this page in my footer,too.

    i tested [‘genesis_post_title] and [genesis_do_post_title], nothing happens.

    • Bill Erickson says

      Post title isn’t one of the shortcodes that is set up ( http://dev.studiopress.com/shortcode-reference ). You could create your own shortcode though. Put this in functions.php:

      add_shortcode('post-title','post_title_shortcode');
      function post_title_shortcode($atts) {
      global $post;
      return get_the_title($post->ID);
      }

      Then you can use [post-title] as a shortcode anywhere in your site.

      • djmaki says

        thaaaaanks!! IT works 🙂
        There is only a small fail (on category or home section, it shows the title of the last entry in this section) but no matter!
        THHHHHHHXXXXXXXXXXXX!!!!!!!!!!!!!!!!

        • Bill Erickson says

          Yes, the post title only works on individual posts. Here’s how to limit the [post-title] to only work on single posts


          add_shortcode('post-title','post_title_shortcode');
          function post_title_shortcode($atts) {
          global $post;
          if(is_single()) return get_the_title($post->ID);
          }

  2. Dina says

    Excellent post. By the way, if I want to add a background image to a navigation menu, how do I do that. I looked at the tutorial on Studiopress website but what I didn’t understand was, do I have to add something to the function.php file? Do I need to remove anything from style.css before adding the css for the new custom menu?

    Thanks mate!

    • Bill Erickson says

      No, you shouldn’t have to edit the functions.php file. Inside style.css in your child theme you will modify the css relating to the nav menu. For example, you might add this:

      #nav {background: url(‘images/nav-bg.jpg’) repeat-x;}

  3. Greg Rickaby says

    This saved my life today:

    unregister_sidebar(‘sidebar’);
    unregister_sidebar(‘sidebar-alt’);

    Thank you Bill.

    Love,
    Greg

    • Bill Erickson says

      Haha I’m glad it helped. I use unregister_sidebar(‘sidebar-alt’) on almost every project.

  4. Paul de Wouters says

    to completely remove the footer, use this code :
    // Remove Footer
    remove_action(‘genesis_footer’, ‘genesis_do_footer’);
    remove_action(‘genesis_footer’, ‘genesis_footer_markup_open’, 5);
    remove_action(‘genesis_footer’, ‘genesis_footer_markup_close’, 15);