James Fishwick

  •  Minimal
  •  CSS Tomfoolery

Web App mode leaves users stranded when following image links when using WPTouch with W3 Total Cache

Note to Self, Page Performance, WordPress

No Comments


Share this post

In most of the posts on my client’s site, embedded images link to the actual image file. I’ve also enabled Web-App mode via WPTouch. In web-app mode images linked to their larger versions shouldn’t open; since Web-App mode has no back button, a user can follow a link to a image and become “stranded” there.

I’m also using W3 Total Cache, which appends the param string like “?9d7bd4″ to all my images. This makes sure that if you change your browser cache policies all users immediately see that change.

However, apparently the appended image string allows for the images to be clicked on and stranded. Interferes with whatever is stripping the image links.

Best way to avoid this:

Go to “Browser Cache.”

At the bottom, you have checked the following setting:

Prevent caching of objects after settings change
Whenever settings are changed, a new query string will be generated and appended to objects allowing the new policy to be applied.

This adds an appropriate string to the end of all images called through CDN or otherwise. Uncheck that box and purge/refresh the cache to see the difference.

Yay. Be stranded no more.

Read more

Proper Bitnami WordPress permissions

Server Admin, WordPress

No Comments


Share this post

Total pain that you have to get switching permissions back and forth for sftp and inline updates! Here’s what they should be to have WP able to do change stuff around natively


chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs
find /opt/bitnami/apps/wordpress/htdocs -type f | xargs chmod 664
find /opt/bitnami/apps/wordpress/htdocs -type d | xargs chmod 775
chmod 664 /opt/bitnami/apps/wordpress/htdocs/.htaccess
chmod 664 /opt/bitnami/apps/wordpress/htdocs/wp-config.php

Read more

Conditional Tags for Custom Post Types & Taxonomies

Code Snippet, Note to Self, WordPress

No Comments


Share this post

Most WordPress instances used to power a full site or shop will hopefully take advantage of the power combination of Custom Taxonomies and Custom Posts. Often you want to style a list of your Custom Posts by Custom Taxonomy and have the single view styled in the same way, or perhaps have the same sidebar. You can do this with by leveraging the Template Hierarchy and registering tons of sidebars. However, before long, you can find your theme folder bloated with extra templates. I don’t like having tons of templates in my themes. Too much code duplication usually. Rather, I like to use Conditional Tags and get_template_part. When dealing with Custom Taxonomies & Post Types it may not be clear at first how one can best use Conditional Tags to good use. Lets take a look.

Read more

Modernizr and jQuery and wp_enqueue_script oh my

Code Snippet, Javascript, Note to Self, WordPress

No Comments


Share this post

Some questions on the best way to use Modernizr with jQuery in the context of WordPress…

I want to be able to use jQuery in my complete callbacks. I, of course, want to be able to use wp_enqueue_script.

Read more

Committing to WordPress svn via proxy

Networking, Note to Self, WordPress

No Comments


Share this post

Multiple times when I was recently updating my svn repository for my Jetpack Easy Playlists plugin, I wasunable to connect to the WordPress SVN repository and execute basic svn commands. Kept getting warnings that looked like this:

svn: warning: Error handling externals definition for XXXX
svn: warning: PROPFIND of '/!svn/XXXX/default': could not connect to server (http://plugins.svn.wordpress.org)

Strangely, I was able to browse the repository via my browser, as well as checkout other public svns. I’m not behind a proxy, with a normal COMCAST connection.

What gives and how did I get around it?

Read more

Get first child page in WordPress

Code Snippet, Note to Self, WordPress

No Comments


Share this post

Often times in WordPress, you’ll create a  parent page and subpages to order the information displayed in your menu. Although many themes are updated to take advantage of the newish WP Menu functionality, not all are. Or maybe you just want the damn menus to be made programatically. I mean, its all very well and good to be able to manually set menus, but we are programmers, are we not?!

Say I want to load in automatic the content of the first subpage when I click on the parent page.  The parent page is simply acting as a container, has no actually content of its own , and I don’t want it to show.

MAIN MENU: A B C

Page A has 3 subpages: a b c

When I click on main menu A link the content of subpage a is loaded in automatic and display.

Check it:

Read more

Wrong comment count after XML import

Code Snippet, Note to Self, PHP, WordPress

No Comments


Share this post

After transfering a WordPress.com blog to a provite domain, I noticed that I couldn’t, for the life of me, get the correct comment count to show. Funny thing was that my if (have_comments ()) statement was returning true, and the comments were in fact displaying. My theme was depending on get_comments_number() to return correctly so

<h3 id="comments-title"><?php printf( _n( 'One Response to %2$s', '%1$s Responses to %2$s', get_comments_number(), 'woothemes' ), number_format_i18n( get_comments_number() ), '<em>' . get_the_title() . '</em>' ); ?></h3>

would return something like “6 RESPONSES TO FOUR WAYS I’M DOING FLOWERS RIGHT NOW.” Instead all I saw was

Read more

Display current template filename in WordPress

Code Snippet, Note to Self, PHP, WordPress

No Comments


Share this post

Sometimes when you’re customizing a WordPress theme with tons of templates, its not always obvious which one is responsible for the output you see. You don’t always want to rack your brains over the template hierarchy, nor do you want to edit every page just to see what’s in the drop-down.

Here’s a quick-and-dirty way to spit out filename of the template used in your current view:

Read more

Pagination in WordPress: Page X of Y

Code Snippet, PHP, WordPress

No Comments


Share this post

Man, I hate deadbeat stackoverflow users. But a useful question (and answer) I think: http://stackoverflow.com/questions/5923388/displaying-wordpress-page-number-count-in-relation-to-siblings

Here’s a quick recipe for use on child pages. Works in your sidebar or template. This tells you that you are on page X of Y out of the child pages of a particular parent.

Read more

display all tags “inside” a given category

Code Snippet, PHP, WordPress

No Comments


Share this post

To be used on a category/archive page in WordPress. Outputs all the tags used in all the posts in the category.

<?php
	// get the category ID of whatever category we are looking at the archives of
	$category_id = get_query_var('cat');
	// get the ids of all the posts in the cat
	$post_ids = get_objects_in_term( $category_id, 'category' );
	// get all the tags from these posts
	$tag_ids = wp_get_object_terms( (array) $post_ids, 'post_tag', array('fields' => 'ids') );
	$tag_param = '';
	if ( ! empty($tag_ids) ) {
	//change 'include=' to 'exclude=' to achieve the opposite..
	$tag_param = 'include=' . implode(',', (array) $tag_ids );
	}
	//format the output using wp_tag_cloud parameters see:
	//http://codex.wordpress.org/Function_Reference/wp_tag_cloud#Parameters
	wp_tag_cloud('count=0&order=RAND&smallest=8&largest=22&'.$tag_param); // don't forget to tack on your includes
	?>

Note that you can also pass this to get_tags(), which you can use to roll your own list of links. For instance, I recently did something like:

	$tags = get_tags('orderby=count&order=DESC&'.$tag_param); //beware params are not all the same
	$html = '<div id="port-tags">';
	foreach ($tags as $tag){
		$tag_link = get_tag_link($tag->term_id);

		$html .= "<a href='{$tag_link}' title='{$tag->name} tag' class='{$tag->slug}' data-filter='.tag-{$tag->slug}'>";
		$html .= "{$tag->name}</a>";
	}
	$html .= '</div>';
	echo $html;

Read more