Menu Sidebar
Menu

SitePoint Podcast Interview for Professional WordPress

Last week Hal Stern, David Damstra, and myself had the privilege of being interviewed on the SitePoint Podcast for our new book Professional WordPress!SitePoint Logo

I had a great time discussing our book with hosts Patrick O’Keefe and Stephan Segraves. We covered many different topics including how the book came to be, what separates our book from the rest, and how our book is a solid compliment to the Codex. We also had a great discussion about the difference between a WordPress Theme and a Theme Framework, which I think a lot of people are still a little confused by.

Professional WordPress Book CoverIt’s a little strange being on the other side of the interview table, but I’m starting to get use to it. Promoting a book is a lot of work, but in the end the payoff is well worth it. If you haven’t had a chance to order this book what are you waiting for? Order a copy today and support your favorite WordPress developers!

Also be sure to subscribe to the SitePoint Podcast, which I’m a regular co-host on, if you haven’t already! We discuss the latest news and happenings in the world of web development and design.

Professional WordPress Has Hit The Shelves!

I’m extremely excited to announce that Professional WordPress, a book I co-authored, has hit the shelves at major book retailers nation wide! The book is also in stock on Amazon.com!
Professional WordPress BooksThis journey started in April of 2009 when Matt Mullenweg posted a blog post that Wiley was looking for WordPress enthusiasts to author a new book. I emailed Carol Long that night and before I knew it was one of the co-authors chosen for Professional WordPress along with Hal Stern and David Damstra!

The entire process was quite a learning experience since I had never written a book before. Luckily Wiley/WROX has an amazingly talented staff that helped guide us during this book writing journey. Hal and David were also great co-authors to work with during the process.

Professional WordPress is a book written by programmers for programmers. We take a more in-depth look at WordPress to help explain how WP works from the inside out. Learn how to create powerful plugins to handle any task. Explore how to build amazing themes using the latest features in WordPress. Learn how to use WordPress as a CMS. We even cover WordPress in the Enterprise and migrating to WordPress from another system. This book has something for everyone so make sure you pick up a copy today and help support your favorite WordPress hackers!

Keep an eye on this blog as I’ll be giving away a few copies of Professional WordPress in the coming weeks!

How To: Remove Default Profile Fields in WordPress

A few days ago I came across an interesting challenge in WordPress. I wanted to hide some of the default profile fields from being displayed to the users in WordPress. Specifically I wanted to hide the AIM, Yahoo IM, and Jabber / Google Talk fields. It took a bit of digging but I found the below function buried in the WordPress.org support forums. Just place the below code in your themes functions.php file to remove these fields:

<?php
add_filter('user_contactmethods','hide_profile_fields',10,1);

function hide_profile_fields( $contactmethods ) {
  unset($contactmethods['aim']);
  unset($contactmethods['jabber']);
  unset($contactmethods['yim']);
  return $contactmethods;
}
?>

That’s it! As you can see below the three fields are removed from the Profile page on the WordPress admin side. This makes it much less confusing for users since they don’t see fields that we aren’t using on the website.

How To: Hide an Admin Menu in WordPress

Have you ever needed to hide a specific admin menu from other users in WordPress? Maybe you want to hide the Plugins and Appearance menus to keep your users out of trouble. Just place the below code in your themes functions.php file to hide the Plugins menu from all users except for admin:

<?php
add_action('admin_head', 'hide_menus');

function hide_menus() {
	global $current_user;
	get_currentuserinfo();
	
	If($current_user->user_login != 'admin') {
		?>
		<style>
		   #menu-plugins{
				display:none;
			}
		</style>
		<?php
	}
}
?>

As another example lets say we want to hide the Links menu from all users that aren’t administrators in WordPress. The below code would do just that:

<?php
add_action('admin_head', 'hide_menus');

function hide_menus() {
	if ( !current_user_can('manage_options') ) {
		?>
		<style>
		   #menu-links{
				display:none;
			}
		</style>
		<?php
	}
}
?>

This is a pretty simple method of hiding menus in the WordPress admin dashboard. Enjoy!

How To: Load User Info Using the Admin Email in WordPress

Today’s handy WordPress code snippet is a simple way to retrieve user data based on the administrator email in WordPress. The email account I am referring to is the one listed under Settings > General and is the main admin email for your website.

$admin_email = get_option('admin_email');
$admin_user_id = get_user_id_from_string($admin_email);
$user_info = get_userdata($admin_user_id);

The above code example first loads the admin email from the WordPress options. Next it determines that user’s ID based off of their email address using the get_user_id_from_string() function. Finally we use get_userdata() to load all user data for that user ID.

Currently the get_user_id_from_string() function is only available in WordPress MU. I have confirmed however that this function does exist in WordPress 3.0. That means after the merge this function will be available to all sites running WordPress.

We can also use the get_user_by_email() function included since WordPress 2.5 to accomplish the same task. Thanks to Mo Jangda for pointing that out in the comments. Below is an example using this method:

$admin_email = get_option('admin_email');
$user_info = get_user_by_email($admin_email);

This is actually a more efficient method as we don’t need to call the function to retrieve the user ID first. In the world of WordPress you learn something everyday. Thanks Mo Jangda!

Custom Post Type UI Plugin for WordPress

A few days ago I released a new plugin for WordPress called Custom Post Type UI. This plugin allows you to easily create custom post types in WordPress without writing a single line of code!

Using custom post types is the future of WordPress and really opens the software up to be a full fledged Content Management System (CMS). For example if you are building a website for a car dealer you could create a post type for Cars. A business directory could have a post type for Businesses. A movie database could have a post type for Movies, Actors, and Directors. I think you get the idea. Post types are a very powerful feature in WordPress and my new plugin helps you take advantage of the power!

Below are some screenshots showing the plugin in action:


Easily create new custom post types


New custom post type is automatically added to your admin menu


Easily view and edit existing custom post types

This plugin is a little different than my other plugins because it is primary built for WordPress 3.0, which hasn’t been officially released yet. You can however install WordPress 3.0-alpha very easily using the WordPress Beta Tester plugin created by Peter Westwood.

All custom post types are saved as a single WordPress option in the database keeping this plugin very lightweight. A future version will include creating custom taxonomies for custom post types. I hope this plugin will be rolled into the Core WordPress software at some point, but until then the Custom Post Type UI does the trick!

How To: Add a Post Thumbnail to an RSS Feed in WordPress

Have you ever needed to add the WordPress post thumbnail to an existing RSS feed? The below code will add a new element named <thumb> to your RSS feed. This element will contain a link to the post thumbnail as set in WordPress:

function ThumbRSS() {
	global $post;
	if ( has_post_thumbnail( $post->ID ) ) { 
		$thumbpic = get_the_post_thumbnail( $post->ID, 'thumbnail' ); 
	}
	
	echo '<thumb>'.$thumbpic.'</thumb>';
}

add_filter('rss_item', 'ThumbRSS');

Keep in mind using this technique will devalidate your RSS feed as the <thumb> element is not a part of the RSS specification. An alternate approach is to attach the post thumbnail to the beginning of your post content in your RSS feed. Below is an example using this method:

function ThumbRSS($content) {
   global $post;
   if ( has_post_thumbnail( $post->ID ) ){
       $content = '<p>' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '</p>' . $content;
   }
   return $content;
}

add_filter('the_excerpt_rss', 'ThumbRSS');
add_filter('the_content_feed', 'ThumbRSS');

Just drop either code example in your themes functions.php file for this to work. Pretty easy huh? Now you can easily include post thumbnails in your WordPress RSS feeds!

My Interview on the WordPress Weekly Podcast

Yesterday I had the pleasure of being interviewed by Jeff Chandler on the WordPress Weekly Podcast! It was great to be back on the show, even though the spotlight was on me this time. I’ve been participating on the WP Weekly podcast since the start (episode 1) so it was fun to reminisce a bit about how we both started into WordPress and how the podcast came to be.

Hal Stern also joined in at the beginning of the show to discuss our new book, Professional WordPress. Jeff and I also discussed many different topics including the challenges of running a business around open source, secret projects in the works, my thoughts on WordPress and how it compares to other open source CMS solutions, and much more! Be sure to check out the episode and let me know how I did!

Professional WordPress Is In Production!

Professional WordPress, the new book I co-authored, is officially in production!

WordPress LogoAfter a 4 month writing phase, and 1.5 month editing phase, we have finally completed the book! I’m extremely excited for this book to hit the store shelves and really believe it’s going to be well received by the WordPress Community.

This book is really different than any other WordPress book on the market. Professional WordPress is a more internals look at WordPress and how it functions. We dive into the Core code and review built-in functions and APIs available for use when extending WordPress.

My favorite chapter of the book is the plugin development chapter. I honestly believe this chapter is worth the price alone. If you are interested in creating custom plugins in WordPress, or even if already know how but want to expand your knowledge, this is the book for you!

You’ll learn the correct way to use the Settings API when developing plugins. We also cover data validation and security to make your plugins as secure as possible. This chapter covers everything you need to know to create amazing plugins the correct way in WordPress!

This book was written by myself and David Damstra. Our Technical Editor was Hal Stern. Mike Little, the co-creator of WordPress, was also a Technical Editor and helped verify the methods we used were always the most appropriate and up-to-date.

Be sure to pre-order a copy of Professional WordPress today! If you’d like to share this link please use http://tinyurl.com/prowp. The official release date is April 5th, 2010.

Newer Posts
Older Posts

Brad Williams Blog

WordPress and the Web

Who is Brad?

Brad Williams picture

Brad Williams is a computer programmer and tech junkie who enjoys exploring technology and sharing his knowledge and experience with others.

 

CEO of WebDevStudiosMaintainn, and Pluginize. Co-author of Professional WordPress and Professional WordPress Plugin Development.

 

Brad resides in Philadelphia.

 

 Subscribe in a reader

Professional WordPress Third Edition

Professional WordPress Plugin Development