monkeybrain on "List posts for each taxonomy/tag of a custom post type"

ساخت وبلاگ

I try to build a restaurant menu for clients.
I created a custom post type 'menu' and registered a taxonomy for it.
register_taxonomy( 'categories', 'menu', array( 'hierarchical' => true, 'label' => 'Categories', 'query_var' => true, 'rewrite' => true ) );

Now I'd like to display the menu items for each tag (appetizers, main course, desert, beverages, etc).
I found some code that does exactly that , it outputs the category name and then lists the posts within that category. Does anyone know how to modify this code to make it work with the taxonomy of a custom post type?

<?php
// get all the categories from the database
$cats = get_categories();
// loop through the categries
foreach ($cats as $cat) {
// setup the cateogory ID
$cat_id= $cat->term_id;
// Make a header for the cateogry
echo "<h2>".$cat->name."</h2>";
// create a custom wordpress query
query_posts("cat=$cat_id&posts_per_page=100");
// start the wordpress loop!
if (have_posts()) : while (have_posts()) : the_post(); ?> <?php // create our link now that the post is setup ?> <a href="<?php the_permalink();?>"><?php the_title(); ?></a> <?php echo '<hr/>'; ?>
<?php endwhile; endif; // done our wordpress loop. Will start again for each category ?>
<?php } // done the foreach statement ?>

Any help would be greatly appreciated. :)

WordPress ...
ما را در سایت WordPress دنبال می کنید

برچسب : نویسنده : استخدام کار wpss بازدید : 103 تاريخ : يکشنبه 29 فروردين 1395 ساعت: 8:08