[wp-hackers] WP Query get dynamic category ID/ CPT
Lee Rickler
info at a5d.org
Mon Apr 30 13:37:45 UTC 2012
Here's one where I'm stumped (regularly happens, I know!)
I have a custom post type (Photos) -> each CPT can be added to various categories.
I need to pull info from the same CPT and also a specific category, depending on which page you're on.
For example:
Current page: Shops
Category: London
CPT: Photos
or
Current page: Shops > London
Category: Sweets
CPT: Photos
There are many, many pages and categories.
My question - Can the category be pulled dynamically (by ID or name) depending on which page you're on?
<?php $loop = new WP_Query( array( 'post_type' => 'shops', 'showposts' => 999, 'category' => 'THIS NEEDS TO BE DYNAMIC DEPENDING ON WHAT PAGE YOU'RE ON' ) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
... do some stuff ...
<?php endwhile; ?>
This one has had me stumped for at least a good while, and might be simply staring me in the face, so I thank you in advance for any pointers.
Lee
More information about the wp-hackers
mailing list