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.
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.
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.
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.
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]
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.
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.
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
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
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
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!
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
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.
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.
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 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
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.
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.