WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

Feb 08 2011

How to Add a Custom Login/Logout Message in WordPress

In a previous post, How to Add a Custom Message on the Login or Register Screen, I talked about how to add a custom message to either the login screen or the register screen. Recently, I was asked how to create a custom message for logging out. Since WordPress uses the wp-login.php file to logout as well, then it isn't as simple as the last post.

So, to add a custom message to your logout screen, you need to add the following to your functions.php file.

[php]function custom_login_head() //outputs the CSS needed to blend custom-message with the normal message
{?>
<style type="text/css">
#login_error, .message { display:none; }
.custom-message {
-moz-border-radius:3px 3px 3px 3px;
border-style:solid;
border-width:1px;
margin:0 0 16px 8px;
padding:12px;
}
.login .custom-message {
background-color:#FFFFE0;
border-color:#E6DB55;
}
</STYLE><?php
}

add_action('login_head','custom_login_head');

function custom_logout_message() {
if ( isset($_GET['loggedout']) && TRUE == $_GET['loggedout'] ) //check to see if it's the logout screen
{
$message = "<p class='custom-message'>Custom logged out Message.</p><br />";
}
else //they are logged in
{
$message = "<p class='custom-message'>Custom Login Message.</p><br />";
}

return $message;
}
add_filter('login_message', 'custom_logout_message');[/php]

Written by Travis Smith · Categorized: Tutorials

Jan 15 2011

StudioPress: WordPress's Best Themes on the Best Framework with SEO & Security Experts and the Best WordPress Support Group

Written by Travis Smith · Categorized: Genesis

Sep 22 2010

Different Favicons for WordPress 3.0 Multisite

Before WordPress 3.0 appeared, I had a different favicon for each of my WordPress sites; however, when I finally made the switch to one WordPress install with Multisite and Domain Mapping, I found that I lost all the various favicons. Typically I use the same two frameworks, and I guess I could create various child theme folders for each site, which would work! However, I'm too lazy to do that and everything that it would entail on enabling themes in the SuperAdmin, etc. (although it would be great to be able to enable themes based on roles!).

So here is what I did in my functions.php file to enable each site in my Multisite installation to have their own favicon. But first, you must place the favicons in the appropriate files folder under wp-content/blogs.dir. So you will need to know the site's ID number, which can be found under the Super Admin > Sites (mydomain.com/wp-admin/ms-sites.php).

[php]/* Different Favicon for Each Site in MS */
function favicon4sites() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="' . get_bloginfo('wpurl') . '/files/favicon.ico" />';
}
add_action( 'admin_head', 'favicon4sites' );
add_action( 'login_head', 'favicon4sites' );
add_action( 'wp_head', 'favicon4sites' );[/php]

If you wanted, you can write different functions to allow for different favicons for the login screen and the admin section but don't forget to remove add_action( 'login_head', 'favicon4sites' ); and add_action( 'wp_head', 'favicon4sites' ); from the previous edit.

[php]/* Different Favicon for the Admin */
function favicon4admin() {
echo '<link rel="Shortcut Icon" type="image/x-icon" href="' . get_bloginfo('wpurl') . '/wp-content/favicon.ico" />';
}
add_action( 'admin_head', 'favicon4admin' );
[/php]

Also note that you can use *.png or *.gif, but they won't work in IE:

[html]<link rel="icon" href="/favicon.png" type="image/png">
<link rel="icon" href="/favicon.gif" type="image/gif"> [/html]

Written by Travis Smith · Categorized: Tutorials

Sep 03 2010

How to Remove the Category Base URL in WordPress (via kmsm)

Courtesy of Joshua Kelly of kmsm.ca

One of the difficulties with using WordPress as a CMS is that the out-of-the-box URL construction is limited. In this respect, categories have particularly poor control.

By default, WordPress constructs category URLs as http://domain/category/category-name and post URLs as http://domain/date/post-name. While you can control most aspects of the post URLs (whether or not to display the month of the post, for example), the only customization available for category URLs is the base name following the domain in which all categories reside (http://domain/series/category-name, for example).

But this can lead to counterintuitive URLs.

For example, if I file a post about about the Godather under a category called Film, the post URL will read http://domain/2010/01/01/the-godfather while the category URL will read http://domain/category/film. This might work well for a blog format, but for large-scale content management, intuitive URLs are a big deal.

Thankfully, we can get WordPress to do our bidding with a simple hack – and it even works with WordPress 3.0!

Let’s say I want to create post URLs in the form http://domain/category/post-name and category URLs in the form http://domain/category-name. Makes sense right? Well here’s how we do that.

Step One: Edit the Post Permalink

Open up WordPress administration panel, and navigate to the Permalinks options screen. Under Common settings, click Custom Structure and enter /%category%/%postname%/ into the field.

Step Two: Edit Functions.php

To edit the category URL structure we have to go into the functions.php file in our WordPress theme. Before the closing PHP bracket, enter the following:
[php]
add_filter('user_trailingslashit', 'remcat_function');
function remcat_function($link) {
return str_replace("/category/", "/", $link);
}

add_action('init', 'remcat_flush_rules');
function remcat_flush_rules() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}

add_filter('generate_rewrite_rules', 'remcat_rewrite');
function remcat_rewrite($wp_rewrite) {
$new_rules = array('(.+)/page/(.+)/?' => 'index.php?category_name='.$wp_rewrite->preg_index(1).'&paged='.$wp_rewrite->preg_index(2));
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}

[/php]
Make sure to save functions.php and upload it to the theme directory.

Now, to go back to the Godfather example, category URLs will look like http://domain/film and post URLs will appear as http://domain/film/the-godfather. Cool eh?

There are other ways of doing this using .htaccess but this is a cleaner approach in that it modifies how WordPress generates URLs, instead of modifying how the server interprets them.

Written by Travis Smith · Categorized: Tutorials

Aug 31 2010

Logos for Mac

Logos Bible Software is giving away thousands of dollars of prizes to celebrate the launch of Logos Bible Software 4 Mac on October 1. Prizes include an iMac, a MacBook Pro, an iPad, an iPod Touch, and more than 100 other prizes!

They’re also having a special limited-time sale on their Mac and PC base packages and upgrades. Check it out!

Written by Travis Smith · Categorized: WordPress

  • « Previous Page
  • 1
  • …
  • 55
  • 56
  • 57
  • 58
  • 59
  • …
  • 61
  • Next Page »
  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

Copyright © 2025 � WP Smith on Genesis on Genesis Framework � WordPress � Log in