Category Archives: wordpress

nice little bit to fix tag archive

Was having a problem with tag archive not pulling from custom post types, or from pages (I added a plugin to add tags to pages). After much searching and minor hair loss, I found this:

function post_type_tags_fix($request) { if ( isset($request['tag']) && !isset($request['post_type']) ) $request['post_type'] = 'any'; return $request; } add_filter('request', 'post_type_tags_fix');

from here:

http://wordpress.stackexchange.com/questions/13237/custom-post-type-tag-archives-dont-work-for-basic-loop

And now the archives work. Added that bit of code to functions.php to get it to work. Using WordPress 3.4.1, surprisingly enough.

hide form option using just css

OK, I know this is cheater. But I don’t know javascript/jquery/whatever, and the plugin people didn’t care to offer this help even as a paid ticket. And this is a deadline here, people. So, after a bit of digging and a very small amount of sweat, I tried this and it WORKS:

form.product select#quantity-48 option:nth-child(n+11){display:none;}

Basically, I’m saying on this form, for this one particular product (number 48) only show me the ability to select up to 10 items.

It doesn’t affect any other product or form, and is not part of the plugin so updates won’t change this in the future. Woot!

the challenge of categories with extra info, and displaying subcategories

I love working with WordPress, but it seems each project comes with an unforseen challenge. This was a new problem: how to only display subcategories on a parent category page, no posts. Because I’m more of a cut-and-paster than a coder, I rely on google to help find solutions. What I was looking for:
– what category are we in? if this category has sub-categories, show those, and if this category has no sub-categories, show posts.
Couldn’t find anything that includes finding the current category. So, I created a new template just for the one category that had subcategories.
This bit of code:
'mycategoryname' , 'post_type' => 'mycustomposttypename',);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>

wp_reset_query(); ?>
does what I need.