Remove Stylesheet Properties

This can be a handy utility. By using Text Wrangler you can open a stylesheet and use the search and replace function. When searching be sure to check the regular expressions option.

Hide WordPress Plugins

Have you ever wanted to hide a plugin from the list of plugins in the WordPress admin? You may want to hide a plugin so the client doesn’t accidentally deactivate or delete it. Or maybe it’s just a utility plugin the a client doesn’t need to see or mess with the settings of. The code snippet below will completely hide a plugin from WordPress plugins list on the Admin side.

Remove Dashboard Widgets

Are you wanting to to remove the default meta boxes from the WordPress Dashboard or remove meta boxes from particular posts or pages. the WordPress functions below will do just that for you. Simply copy and paste the code below into you functions.php file located in your theme folder. Then make sure to customize the function as you see need.

PHP Foreach Loop

The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects, and will issue an error when you try to use it on a variable with a different data type or an uninitialized variable. There are two syntaxes.

Custom Database Queries

If you need something more than what the default WordPress functions give you, you can use $wpdb, the WordPress database class to query the database directly. [php] $recent_users = $wpdb->get_results( "SELECT display_name, user_registered FROM $wpdb->users ORDER BY user_registered DESC LIMIT 0,10" ); [/php]

Storing the Original wp_query

Multiple loops are great but can wreak havoc if not used correctly. To make sure your loop runs smoothly and you can still use all of the functions that rely on globals, store the original query in a temporary variable.

Custom Profile Fields

I can’t say that WordPress offers much in the way of profile customization in the administration area. Especially nowadays, when you want to show the Twitter and other social accounts of authors, this is a shortcoming. It can be fixed easily, though.

Twitter-Like Time Display

This is a fantastic function, especially since it has been in WordPress since version 1.5! If you want to display a relative date in a human-readable format, like “5 minutes ago” or “one month ago,” try the human_timed_diff() function. Example 1 [php] $diff = human_time_diff( ‘2012-05-05 12:05:00’, ‘2012-05-05 12:10:00’ ); echo ‘This comment was submitted  … read more

Upload Files With Ease

WordPress has a bunch of great uploading functions for everything from checking the file type to finding the uploads directory. A more obscure function is wp_upload_bits(), which you can use to upload a file to the uploads directory. [php] $upload = wp_upload_bits( $_FILES[‘myfile’][‘name’], null, file_get_contents( $_FILES[‘myfile’][‘tmp_name’] ) ); echo ‘Well uploaded! The path to this  … read more

List all hooked WordPress functions

WordPress hooks are very useful because they allow you to “surcharge” an existing WP function with your own code. But when things goes wrong, it should be useful to be able to list all hooked WordPress functions. Here is the code to it. The first thing to do is to paste the following function in  … read more

Remove User from Users List

Want to hide yourself from the users list in the WordPress admin. It’s pretty quick and easy. There are lots of reasons you might want to do this. I won’t expand on that anymore but I’m sure you can have fun with it!

Register a New WP Role

Create Custom Roles for Your Website A Role defines a set of tasks a user assigned the role is allowed to perform. For instance, the Super Admin role encompasses every possible task that can be performed within a Network of virtual WordPress sites. The Administrator role limits the allowed tasks only to those which affect  … read more

Hide Post Editor

Customizing the post editing screen can be very helpful when creating a clients website. With custom meta boxes and meta data clients can feel good about adding, editing and publishing content. Additionally you can remove meat boxes or even the post editor all together. Slimming down the post editing screen can cut down on confusion for the client when going to create new content.

Find & Replace With SQL

This can be a super useful SQL statement when fro example migrating a WordPress website manually, or after importing tables from another WordPress website. The few statements below will suffice for a WordPress migration. Although if you have plugins that create their own tables in the database you may need to update this as well.

Register Custom Image Sizes

Custom image sizes are almost a must when developing a website for a client. If you create customize sizes for your clients website you can ensure that when the client adds an image to a post it will be the correct size on the front-end, helping resolve broken layout issues I have seen many, many times.

Check For a Featured Image

Check for the Post Thumbnail The Post Thumbnail is an image that you select to represent your posts content. Generally it’s the small thumbnail image you see beside a posts excerpt. [php] <?php global $post ?> <!– Check if a Post Thumbnail has been assigned –> <?php if ( has_post_thumbnail() ) : ?> <?php //Create  … read more

Enqueue Stylesheets

A safe way to add/enqueue a CSS style file to the wordpress generated page. If it was first registered with   wp_register_style() it can now be added using its handle.

Remove Admin Menus

This filter hook function will allow you to remove specific menu items and admin pages from the WordPress admin screen. Sometimes it is nice to remove unnecessary menu items and particular admin pages for a client website. If the client isn’t going to use it then in my option it would be a good idea to remove them. This helps declutter the admin interface for the client and keep things nice and clean for them.