by

If you’re using the Genesis Framework and a and a child theme, you may have noticed that there are some credits appearing at the bottom of every page in the footer. You can change these credits so that they appear exactly how you want them to, with the links you want. In this tutorial, I’m going to show you how.

This tutorial uses a customized version of the Centric Pro Theme, but this code snippet will work on any Genesis child theme.

First, the original code

Here is the original code with the original credits from StudioPress:

//* Customize the credits
add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
function sp_footer_creds_text() {
echo '

';
echo 'Copyright © ';
echo date('Y');
echo ' · My Custom Link · Built on the Genesis Framework';
echo '

';
}

Next, the modified code

And here is that same code with my modifications:

//* Customize the credits
add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
function sp_footer_creds_text() {
echo '

';
echo 'Copyright © ';
echo date('Y');
echo ' · Customer Servant Consultancy Inc. · Backed by WP Engine, · Built on the Genesis Framework · using a highly customized version of the Centric Pro Theme';
echo '

';
}

What is this doing and how do I change it?

This code is made up of a filter, and a function with some echo statements. A filter is a function that changes another function. Instead of having to rewrite the function you want to change, you can use a filter to change the function by taking a piece out or adding a piece, and it’s one line of code instead of an entire function.

So in this case, we already have a function called genesis_footer_creds_text, and we want to make some changes to that function with our new function, sp_footer_creds_text. The original function lives in the core of the Genesis framework, and changing it this way saves us the time we’d spend finding the original function, copying it to the child theme, and then changing it. We can use sp_footer_creds_text to make only the changes we need while leaving the rest of the genesis_footer_creds_function intact.

As part of the sp_footer_creds_text changes, we have some echo statements. Echo statements are used in PHP to output text to the screen. In our case, they’re being used to output the copyright statement and some links. As you’ll notice in the code samples above, they can take HTML markup.

The first statement echoes, (or outputs) the beginning of the HTML with classes from the CSS so the credits will display properly with their appropriate styling. The second echo statement uses PHP time and date parameters so that the current year is automatically generated, which means we don’t have to change it every year manualy. It also includes the link to the copyright holder, and it can also include text with no link. There’s also some code that generates some punctuation. You can’t just write the punctuation in because PHP uses half the punctuation marks in the English language to do other stuff. So we have to tell PHP that we actually want to output the punctuation to the screen, not interpret it.

A note on copyright

According to U.S. copyright law, (here), the year of first publication also has to be visible in order for copyright to be valid. There is a shortcode you can use that will help with including the first date of publication: [footer_copyright first="201x"] where “x” is the last digit of the year of first publication. Thanks Gary Jones for the tip.

The rest of the echo statements contain links to the Genesis framework, and, in my modification, the link to the child theme I’ve modified. You can add as many of these as you like.

The final echo statement outputs the closing HTML markup so that we don’t end up with open tags and break the display. Finally, we close the function with a curly bracket.

If your child theme already contains a function that customizes the credits, you can remove that function and use this one, or customize the function that’s there. And of course, all of this goes in your theme’s functions.php file, since it controls how something is displayed on your site.

An Alternative Function with Shortcodes

As I mentioned in the copyright note above, there is a shortcode you can use to generate your copyright statement. There are also shortcodes you can use to generate the link back to StudioPress and the Genesis framework, as well as the child theme link. Here’s a function using those example shortcodes.


add_filter('genesis_footer_creds_text', 'custom_footer_creds_text');
function custom_footer_creds_text($creds) {
$creds = '[footer_copyright]' . get_bloginfo('name') . ' • Built on the [footer_genesis_link] powered by [footer_wordpress_link]';
return $creds;
}

In the above function, shortcodes are being used to generate the current year of the copyright statement, the blog name, the Genesis framework link, and the WordPress link. All of these shortcodes have attributes that can be used. For instance, for the [footer_copyright] shortcode, you can use the “first” attribute to specify the first year of publication, like this:

[footer_copyright first="20xx"]
Within the quotes, add the first year of publication, such as 2005.

Customizing the credits at the bottom of your Genesis powered site lets you add a more personal touch, and gives you just a little bit more control. If you have any questions about this tutorial, feel free to leave them in the comments.


Respond

Leave a Reply

Discuss this

Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.