开发者

wordpress 3: create navigation menu for a custom post type

Just playing around with Wordpress 3.0 for the first time. I've installed the Custom Post Type UI plugin, and have created a custom post type: "composers".

How do I go about creating a navigation menu for all the composers? Ideally, I'd like a static page entitled 'composers' which has a nav menu of all the individual composers.

In the Appearance -> Menus page, I can create a men开发者_高级运维u and assign composers individually to it, but what do I need to do to just add the entire collection of composers to a menu, so that it updates when I add a new composer? Surely I don't have to add them all manually?


What you're trying to do might be better achieved as a plugin, or a little editing in your theme file, something along the lines of;

$composers = new WP_Query('post_type=composers');
if ($composers->have_posts():
?>
<ul class="composer-nav">
    <?php while ($composers->have_posts()): $composers->the_post(); ?>
        <li>
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        </li>
    <?php endwhile; ?>
</ul>
<?php endif; ?>

I know the idea behind custom menus was to try and avoid the need for plugins or theme editing, but I think it was truly designed for users to be able to pick and choose exactly what they wanted, rather than automatically listing items (just my opinion).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜