WP Smith

Creating WordPress & Genesis Websites Since 2010

  • Home
  • About
  • Services
  • Blog
  • Contact

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

Jul 27 2010

Using Custom Menus to Create Custom Menus Based on Role/Capabilities

So thanks to Nathan Rice (@nathanrice), creator of Genesis, I was able to complete my code to create menus based on user roles and capabilities. On one of my sites, the user wanted to display three different menus based on one's user roles and capabilities:

  1. One to display if a person was a Contributor or higher (read, edit posts, etc.).
  2. One to display if a person was a Subscribor (read)
  3. One to display for a visitor (none)

So as I stumbled through the code, here is the final code for Genesis Users. For non-Genesis users simply change 'menu_class' => genesis_get_option('nav_superfish') ? 'nav superfish' : 'nav', to 'menu_class' => '',. And you will need to change the add_action and remove_action code.

[php]//Custom Menu Based on Roles/Capabilities
remove_action('genesis_after_header', 'genesis_do_nav');
add_action('genesis_after_header', 'custom_genesis_do_nav');
function custom_genesis_do_nav() {

if ( current_user_can('edit_posts') ) {
$nav = wp_nav_menu(array(
'theme_location' => 'primary',
'menu' => 1,
'container' => '',
'menu_class' => genesis_get_option('nav_superfish') ? 'nav superfish' : 'nav',
'echo' => 0
));
printf( '<div id="nav"><div class="wrap">%s</div></div>', $nav );
}
elseif ( current_user_can('read') && !current_user_can('edit_posts') ) {
$nav = wp_nav_menu(array(
'theme_location' => 'primary',
'menu' => 2,
'container' => '',
'menu_class' => genesis_get_option('nav_superfish') ? 'nav superfish' : 'nav',
'echo' => 0
));
printf( '<div id="nav"><div class="wrap">%s</div></div>', $nav );
}
elseif(!current_user_can('read') && !current_user_can('edit_posts') ) {
$nav = wp_nav_menu(array(
'theme_location' => 'primary',
'menu' => 3,
'container' => '',
'menu_class' => genesis_get_option('nav_superfish') ? 'nav superfish' : 'nav',
'echo' => 0
));
printf( '<div id="nav"><div class="wrap">%s</div></div>', $nav );

}
else //just in case
{
genesis_do_nav();
}

} [/php]

To get the menu id number, simply go to Appearance > Menus. When you mouse over the menus, you should see a URL like http://mydomain.com/wp-admin/nav-menus.php?action=edit&menu=44. The menu=44 is your menu ID. When you click on them the URL should appear in the address bar if you cannot see the URLs in the status bar.

Written by Travis Smith · Categorized: Tutorials

  • « Previous Page
  • 1
  • …
  • 54
  • 55
  • 56
  • 57
  • 58
  • …
  • 60
  • Next Page »

Need Help?

Please let us know how we can help you!

Get Help

Recommendations

Genesis WordPress Framework
Sucuri Security
Gravity Forms
GetSoliloquy
Get Envira
Scribe SEO
BackupBuddy
WordPress Video User Manuals

Recent Posts

  • Solving WordPress 5XX Server Errors on SiteGround
  • Hiding an User in the WordPress Admin
  • Custom Rewrite Rules for Custom Post Types and Taxonomies
  • WordPress JavaScript Manager Native Functions
  • Causes of WordPress Site Performance Slowdown

About Travis

As a WordPress enthusiast, developer, and speaker, Travis writes about what he learns in WordPress trying to help other WordPress travelers, beginners and enthusiasts with tutorials, explanations, & demonstrations.

  • Twitter
  • Facebook
  • LinkedIn
  • Google+
  • RSS

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