A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

Improve your search engine rankings

Improve your search engine rankings while drudging up memories of your science class.

A simple set of templates for any project

Now that modern browsers are starting to support some of the really useful parts of HTML5 and CSS3, it’s time for our best practices to catch up, and we thought we’d put our files out there for everyone to use. By no means do we see this as the One True Way to start every project, but we think it’s a good starting place that anyone can make their own.

jQuery Auto Complete input field

TextExt is a modern jQuery plugin for improving the functionality of text input fields as tag input and autocomplete.

jQuery Organization Chart

jQuery OrgChart is a plugin that allows you to render structures with nested elements in a easy-to-read tree structure. To build the tree all you need is to make a single line call to the plugin and supply the HTML element Id for a nested unordered list element that is representative of the data you’d like to display.


Setting server variables on multiple domain Magento

When adding another domain to my Magento store I needed to modify the .htaccess file:


RewriteCond %{HTTP_HOST} ^
RewriteRule ^ - [E=MAGE_RUN_CODE:shop_theblueberrypartnership_com]

RewriteCond %{HTTP_HOST} ^
RewriteRule ^ - [E=MAGE_RUN_TYPE:website]

Display login or register links

Display login or register link

<?php if(is_user_logged_in()):?>

<?php else: // not logged in ?>
<?php wp_die('Sorry, you must first '. wp_loginout( get_permalink() ).' to view this page. You can '.wp_register( '', '').'.'); ?>
<?php endif; // logged in? ?>

Flush wp_rewrite rules

As stated on WordPress Codex: Flushing the rewrite rules is an expensive operation. So it’s best to refresh your wp_rewrite rules by not using the init hook.  Austin Passy chooses to Flush your rewrite rules on plugin/theme activation on checking $_GET parameters.  I’ve tried it two different ways.  The first option seemed to work for a while, but my added rule disappeared somehow and began sending requests to a 404 page so I started using the other option.

Option 1:

$custom_permalink_rules_exist = get_option( $this->permalink_rule_option_name );

if( $custom_permalink_rules_exist != "1") {
	add_action( 'init', 'flush_rewrite_rules');
	add_action( 'generate_rewrite_rules', array( &$this, 'add_rewrite_rules' ) );

	update_option( $this->permalink_rule_option_name, '1');

Option 2:

	 * Flushing the wp_rewrite rules is an expensive proceedure so check
	 * if the rules exist
	 * @global object $wp_rewrite
	function verify_rewrite_rule_exists() {
		global $wp_rewrite;

		if( empty($this->rewrite_rule_key) ||
			!array_key_exists($this->rewrite_rule_key, $wp_rewrite->rules ) ) {
			add_action( 'generate_rewrite_rules', array( &$this, 'add_rewrite_rules' ) );

	function add_rewrite_rules( $wp_rewrite ) {
		global $wp_rewrite;

		$this->rewrite_rule_key = "^{$this->post_type_slug}/([^/]*)/([^/]*)/([^/]*)$";

		// match a custom post_type with a parent and child taxonomy
		$new_rules = array( "^{$this->post_type_slug}/([^/]*)/([^/]*)/([^/]*)$" => "index.php?{$this->post_type_slug}=" . $wp_rewrite->preg_index(3) );

		// match a custom post_type with only one taxonomy; however, will break the archive page for two taxonomies
		//$new_rules = array( "^{$this->post_type_slug}/([^/]*)/([^/]*)$" => "index.php?{$this->post_type_slug}=" . $wp_rewrite->preg_index(2) );

		// Add the new rewrite rule into the top of the global rules array
		$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;


		return $wp_rewrite->rules;

Custom Post Type redirects to 404 page

This function from dev4press really helped me debug my custom post type redirect to a 404 page.


Place this code in your functions.php file:

function dev4press_debug_page_request() {
		global $wp, $template;

		echo '<pre>!-- Request: ';
		echo empty($wp->request) ? "None" : esc_html($wp->request);
		echo ' -->'.PHP_EOL;
		echo '!-- Matched Rewrite Rule: ';
		echo empty($wp->matched_rule) ? None : esc_html($wp->matched_rule);
		echo ' -->'.PHP_EOL;
		echo '!-- Matched Rewrite Query: ';
		echo empty($wp->matched_query) ? "None" : esc_html($wp->matched_query);
		echo ' -->'.PHP_EOL;
		echo '!-- Loaded Template: ';
		echo basename($template);
		echo ' --></pre>'.PHP_EOL;

Place this in your template file:


echo '<h1>Rewrite Rules</h1>';

global $wp_rewrite;

echo '<pre>';
echo '</pre>';

Breadcrumbs for Taxonomy for a Custom Post type

This is what I came up with to display the category, or rather a custom taxonomy, of a single posttype page of use in a breadcrumb. The taxonomy I used is ‘smg-logo-brand’ and the terms slug where ‘kcrg’, ‘the-gazette’ and ‘sourcemedia.’ I compared the terms associated with the post to that in the URL to determine which term belonged in the breadcrumb.

if (!is_tax() && get_post_type() == 'smg-logo' && has_term( array( 'kcrg', 'the-gazette', 'sourcemedia', 'other' ), 'smg-logo-brand' ) ) {
			$terms = get_the_terms( get_the_ID(), 'smg-logo-brand' );
			foreach ( $terms as $term ) {
				if ( strpos( $_SERVER["REQUEST_URI"], $term->slug ) !== false) {
					$breads['terms'] = '<a href="/logos/'. $term->slug . '/">' . $term->name . '</a>';

Custom post type capabilities

$custom_posts_caps = array('edit_custom_post',

_smg_add_cap('administrator', $custom_posts_caps);
_smg_add_cap('editor', $custom_posts_caps);

'capabilities' => array(
'edit_post' => 'edit_custom_post',
'read_post' => 'read_custom_post',
'delete_post' => 'delete_custom_post',
'edit_posts' => 'edit_custom_posts',
'edit_others_posts' => 'edit_others_custom_posts',
'publish_posts' => 'publish_custom_posts',
'read_private_posts' => 'read_private_custom_posts'