From the Blogabout me

Genesis Customized Headers (advanced use)

First and foremost – do not ever do this unless you

  1. absolutely know exactly what you are doing
  2. absolutely have to because of some unique reason
  3. absolutely know what you are doing
  4. have read and followed bullet points #1 & #3 perfectly

I absolutely love how the Genesis Framework has been developed and continue to find out things about it.  Every time I think to myself, “Gosh I wish there was a way to…” I realize Genesis developers have already done it some where.  You just have to keep digging.

In very, very rare occasions you will need to put some kind of Shell around your WordPress site.  Maybe you have an organizational brand that needs to be standard across the world, but you want to add a website using WordPress and Genesis.  If that’s the case, you may run into some issues with the required assets if you are not careful.

The piece of code we are changing is demonstrated in the screen capture here.genesis-header

In the most recent Genesis framework (1.9.1 as of today), a function such as genesis_header_markup_open will need to be adjusted.

Find the code by going to
genesis/lib/structure/header.php
and look for the function you are wanting to change.  I will change the Genesis header slightly below.

Original:

function genesis_header_markup_open() {

    genesis_markup( '<header>', '<div id="header">' );
    genesis_structural_wrap( 'header' );

}

Modified:

function genesis_header_markup_open() {

    genesis_markup( '<header>', '<div id="custom-header">' );
    genesis_structural_wrap( 'header' );

}

I’ve had to do this on rare occasions only because my clients had CSS or a structual issue where they were already using the

ID=header

so I had no way other than to make this change via the Genesis framework. I deinifitely do not recommend this as a normal practice, as you will have to change this code every time there is any update to the framework.

I wish you lots of luck.

Featured Images in Genesis – Hiding, Displaying and Removing them.

I’m a huge fan of Genesis and StudioPress as a whole.  Also, Brian Gardner is amazing at ideas and the work he has developed along the way.  Even so, there are occasions when I need to tweak things just a little to fit my  (my clients) needs.

One particular example is making sure the Featured Images of Posts are displaying in the correct places of Genesis. In this short tutorial I am going to display and explain the code for getting the Featured Images to fit your needs. Although I am going to be referring to Genesis code, most of this code can easily be converted to other themes, minus the Genesis calls. Also for simplicity reasons, I will refer to the Agency theme, but again use your Child Theme names where you see “agency” if it helps you.  Feel free to contact me if you have particular questions about the code.

Here are the scenarios:

I want Featured Images on Single Posts (individual Posts all by themselves and nothing else on the screen, or some themes will use single.php as the theme)

Open your Child Theme functions.php (remember we said we are using Agency)
/** Add Post image above post title, single posts only */
add_action( 'genesis_before_post', 'agency_post_image' );
function agency_post_image() {

if ( is_category() ) return;
if ( $image = genesis_get_image( 'format=url&size=post-image' ) ) {
printf( '<a href="%s" rel="bookmark"><img class="post-photo" src="%s" alt="%s" /></a>', get_permalink(), $image, the_title_attribute( 'echo=0' ) );
}
}

What’s going on here, you ask? So let’s go through this – line by line

add_action( 'genesis_before_post', 'agency_post_image' );
= We need to add an action for Genesis to know what to do, so using Genesis hook reference genesis_before_post is what executes before each post in all loop blocks (outside the post_class() div)

function agency_post_image() {
= This is just to start the new function that your aforementioned action will call. You can name it whatever you want to, just use it correctly in the above action as well.

if ( is_category() ) return;
= This code tells Genesis if you are on XYZ page (Category Pages, in this case) to just return nothing and not display anything special. This is the BIGGEST thing to remember, and you will see why shortly.

The last if statement is saying “When we display an image, here is the URL, the size of the image you uploaded, and I am going to print the URL of the original Post/Page the image was a Featured Image of.

Now this is where it gets real fun. Read on…

If you were to change is_category to something slightly different you would get an entirely different outcome, so:

if ( is_category() ) return;
= as originally explained, this makes sure Featured Images do not display on Category pages; but does show everywhere else.

if ( is_page() ) return;
= this makes sure Featured Images do not display on Pages; but does show everywhere else.

if ( is_single() ) return;
= this makes sure Featured Images do not display on Single Posts pages; but does show everywhere else.

Happy Coding