Shortcode for Copyright, Credit and Login Access Sitewide
Once a site is launched, one of the most fundamental tools a client needs is easy access to login and logout of the site. Telling them where the WP login page is located is not something they will typically remember. It’s become quite a lifesaver to put a small footer link on every page that allows them to login, logout, or get back to the dashboard. Also, its a great place to provide attribution back to the site designer, if that’s something you want to do. Couple that with an automatically updating copyright statement and we have a very useful footer snippet!
Use this handy shortcode to display a short line or two of text at the bottom of every page showing your site’s copyright (automatically updated to this year) and a simple login/logout link. It also optionally will provide credit for the site’s designer.
Here’s an Example
Using the Shortcode
- Copy the following into your functions.php file.
- Update the default settings to be your own site designer information.
- Then place the shortcode [credits] into the footer of your site.
// Copyright/Credit/Access Shortcode // Usage: [credits oscredit="false" title="" link="" link_title="" linebreak="true"] // All parameters optional. Defaults set below. add_shortcode('credits', 'opensky_credits_function'); function opensky_credits_function( $atts, $content = null ) { extract( shortcode_atts( array( 'oscredit' => 'true', //set true|false to show or hide designer's credit 'title' => 'Open Sky Web Studio', // designer's name 'link' => 'https://www.openskywebstudio.com', // link to designer's website 'link_title' => 'Open Sky Web Studio | Clean, Effective Websites', // designer's link title for seo 'linebreak' => 'true', // true|false to display on one line or two ), $atts ) ); $creds = "<span id='credits'>Copyright © " . date('Y') . " <a href='".get_option('home')."' title='".get_bloginfo('name')." | ".get_bloginfo('description')."'>".get_bloginfo('name')."</a>. All Rights Reserved. "; if (strtolower($oscredit) == "false") $creds .= "<!--"; if (strtolower($linebreak) == "true") $creds .= "<br/>"; $creds .= "Site Design • <a href='".$link."' title='".$link_title."' target='_blank'>".$title."</a> • "; if (strtolower($oscredit) == "false") $creds .= "-->"; $creds .= wp_loginout('', false) . wp_register(' • ', '', false) . '</span>'; return $creds; }
Thank you Karena for a very useful shortcode!
How would this be coded for a custom login page located at https://yourcompanyname.com/login please?
Thanks mtibesar!
By using the function wp_loginout instead of hard coding the link, it should pull the custom login page for the link even if you’ve changed it.
More info here: https://developer.wordpress.org/reference/functions/wp_loginout/