Wordpress

Code Snippet NameSort by Category CategorySort by Category Submitted BySort by Person   Date

Improved Shortcode

Wordpress 02/15/12
This in an improved version of http://code.hyperspatial.com/1105/function-as-shortcode/ which allows you to use one function for shortcode callbacks. So instead of writing two functions, one for shortcode (must return printed output) and one to call directly, try this output buffer ... View Code

Tags

WP plugin path constants

Wordpress 02/09/12
These constants allow you to automatically access the server path and the plugin url for your wordpress plugins. Despite the directory name. View Code

Tags ,

Page Window

Wordpress 02/01/12
This wordpress class allows you to easily run custom loops on your front page in order to add multiple windows, each with the content from a wordpress page.

Just instantiate the class for each window by passing the page id you want. Then display the title, content or excerpt at will. View Code

Get Gravatar

Wordpress 01/05/12
Use this php function to get a Gravatar image. Gravitars are globally recognized avatars. View Code

Sortable Columns

Wordpress 12/19/11
This Wordpress snippet allows you to add sortable columns to your custom post type list on the WP dashboard. Replace bz_league with the name of your custom post type, especially in the actions and filters. View Code

Tags

Update option hook

Wordpress 12/14/11
I always forget about this Wordpress action, so collectifying it. This action fires when the option 'blogdescription' is changed. In this case I am updating the option 'my_copied_description' to mirror the main one. This is handy for custom admin pages where you are changing a global option. View Code

Tags ,

In class actions

Wordpress 12/05/11
There are a couple ways to work with hooks within classes. Here are a couple of methods to run methods using add_action() View Code

Tags

Comment Meta Box

Wordpress 11/29/11
This Wordpress snippet allows you to add a meta box to the Edit Comment page. The example just prints out a message but you can add whatever you want to the meta box.

The second snippet is used to store meta data upon comment save. I did not set up the first snippet for this, i put the function ... View Code

Tags ,

Comment List Columns

Wordpress 11/29/11
Use this Wordpress snippet to add extra columns to the comments admin page which is edit-comments.php - This basically adds comment meta to the list of comments. View Code

Tags ,

Quick add page style

Wordpress 11/22/11
Just sticking a css block on a wordpress page works great but does not validate w3c - Use this wordpress snippet to add your css block to the head. Just add this to your wordpress page template, like page-mypage.php View Code

Tags

Apply Shortcode to String

Wordpress 11/11/11
This is a quick easy way to apply or parse shortcodes within a string in Wordpress using PHP.

The shortcode in the example is not a default one, so replace it with your own shortcode. View Code

Tags

Dynamic text with shortcode

Wordpress 10/24/11
This wordpress shortcode routine allows you to create unlimited blog options and print them quickly with shortcode. For this example create a few options in the main blog named 'wco_text_test' and 'wco_text_test2'. Then print it using [wco_text term="test"] and [wco_text term="test2"]

To make ... View Code

Tags ,

WPMU flush rewrites

Wordpress 10/20/11
I have been running into issues with custom post types in Wordpress multiuser. When creating new blogs with a custom post type, you will get a 404 page when trying to view the first custom post. This only happens if you set the permalink settings to a non default on new blog creation.

To fix ... View Code

Tags

Admin bar on bottom

Wordpress 10/18/11
Thanks to Matt Price again, this wordpress snippet will move the admin bar to the bottom of the browser. View Code

Tags ,

WP file upload

Wordpress 10/17/11
This is some code By Matt Price to handle Wordpress media uploads. The snippet is for reference only and experimental in nature, the html form is not included View Code

Tags

Parent Body Class

Wordpress 10/12/11
Thanks to Ben for this snippet. Use it to add a top level body class to your wordpress posts or pages. View Code

Tags