There are some odd tricks you end up learning when you use StudioPress’s Genesis Frameworks. Since no one actually uses the framework as the theme, we’re all downloading children themes and then editing them.
I have to be honest here, I hate editing child themes. That’s why I’ve begun making a functional plugin to ‘grandchild’ the themes. There are some subtle differences, however, in how one approaches code for a grandchild vs a child ‘theme,’ and one of them is how the credits work.
Normal Genesis Overrides Are Simple
At the footer of every page for a StudioPress theme is a credit line. It reads out the year and a link to your theme and Genesis, and done. If you don’t like it, you can edit it like this:
//* Change the footer text add_filter('genesis_footer_creds_text', 'sp_footer_creds_filter'); function sp_footer_creds_filter( $creds ) { $creds = '[footer_copyright] · <a href="http://mydomain.com">My Custom Link</a> · Built on the <a href="http://www.studiopress.com/themes/genesis" title="Genesis Framework">Genesis Framework</a>'; return $creds; }
If you’re not comfortable with code, I recommend you use the Genesis Simple Edits plugin. But …
What happens when your child theme already filters the credits?
Grandchild Genesis Overrides are Not
My child theme includes a filter already, called CHILDTHEME_footer_creds_filter
, and it’s not filterable. That means I can’t just change the add filter line to this:
add_filter('genesis_footer_creds_text', 'CHILDTHEME_footer_creds_filter');
That’s okay, though, because I knew I could use could use remove_filter()
to get rid of it like this:
remove_filter( 'genesis_do_footer', 'CHILDTHEME_footer_creds_filter' );
Except that didn’t work. I kicked myself and remembered what the illustrious Mike Little said about how one could replace filters in a theme (he was using Twenty Twelve):
… your child theme’s functions.php runs before Twenty Twelve’s does. That means that when your call to
remove_filter()
runs, Twenty Twelve hasn’t yet calledadd_filter()
. It won’t work because there’s nothing to remove!
Logically, I needed to make sure my filter removal runs after the filter is added in the first place. Right? Logical.
The Credit Removal Solution
Here’s how you do it:
add_action( 'after_setup_theme', 'HALFELF_footer_creds' ); function genesis_footer_creds() { remove_filter( 'genesis_do_footer', 'CHILDTHEME_footer_creds_filter' ); add_filter( 'genesis_footer_creds_text', 'HALFELF_footer_creds' ); } function genesis_footer_creds_text( $creds ) { $creds = '[footer_copyright] · <a href="https://halfelf.org/">Half-Elf on Tech</a> · Built on the <a href="http://www.studiopress.com/themes/genesis" title="Genesis Framework">Genesis Framework</a>'; return $creds; }
That first add_action()
is called after the theme is set up. Then it removes the filter I don’t want and adds the one I do.
Done and done.