Aug
19

Genesis Framework – a Footer shortcode

In the redesign process of my site I wanted to clean up a little the output of footer creds so I wanted to get rid of the wp-login.php link.
It still is there, but I’m hiding it in the © symbol: all done via a custom shortcode.

Let’s create a custom_shortcodes.php file and then put it in a lib folder in our child theme.

In the custom_shortcodes.php let’s write this:

add_shortcode('tg_footer_loginout', 'tg_footer_loginout_shortcode');
function tg_footer_loginout_shortcode($atts) {
 
	$defaults = array(
		'redirect' => '',
		'before' => '',
		'after' => ''
	);
	$atts = shortcode_atts( $defaults, $atts );
 
	if ( ! is_user_logged_in() )
		$link = '<a href="' . esc_url( wp_login_url($atts['redirect']) ) . '">' . __('&copy', 'genesis') . '</a>';
	else
		$link = '<a href="' . esc_url( wp_logout_url($atts['redirect']) ) . '">' . __('&copy', 'genesis') . '</a>';
 
	$output = $atts['before'] . apply_filters('loginout', $link) .' '. date('Y') . $atts['after'];
 
	return apply_filters('tg_footer_loginout_shortcode', $output, $atts);
 
}

In our child functions.php file we customize the footer creds section as always:

add_filter('genesis_footer_creds_text', 'footer_creds_filter');
function footer_creds_filter($creds) {
    $creds = 'Copyright [tg_footer_loginout] [footer_childtheme_link] &middot; [footer_genesis_link] &middot; [footer_wordpress_link] &middot;';
    return $creds;
}

I replaced the [ footer_copyright ] with the [ tg_footer_loginout ] and cancelled the [ footer_loginout ] .

Don’t forget to add these lines just after the require_once(TEMPLATEPATH.'/lib/init.php'); in functions.php.

// Add custom Shortcodes
require_once(CHILD_DIR.'/lib/custom_shortcodes.php');

Comments

  1. blackpearl says:

    How do I add pages like Home || About || Services at the middle of my footer without using genesis shortcode plugin.

  2. blackpearl says:

    Marco, can you emphasis by giving an example on how to create a widgeted in the middle of the footer.

  3. blackpearl says:

    how about removing back to top once and for all?

Comment Policy: Your words are your own, so be nice and helpful if you can. Please, only use your real name and limit the amount of links submitted in your comment. I accept clean XHTML in comments, but don't overdo it please.

Leave a Comment

*

Hire Me