• Resolved Francesco Canovi

    (@thedarkmist)


    I’m sure it’s a silly question, but I’m a newbie.
    I created a CPT. It’s a post-like type. Now I would like to display in the main menu (done with the custom menu) a link to a page where all the CPT posts are diplayed, like the category page does for posts.
    Someone can give me some directions about where to look?
    Thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • You’re going to have to create a custom page template and inside of that template place the code to list the custom post types that you have created.

    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates Shows you how to create a custom page template.

    http://codex.wordpress.org/Function_Reference/get_post_types Shows you how you can list all custom post types (scroll down to the Output a list of all public custom post types section).

    So once you have the page template created just add in the code that lists the custom post types and you should be good to go.

    Thread Starter Francesco Canovi

    (@thedarkmist)

    Ok, but when I have the template with the list, how can I link it in the menu?

    Use the custom link feature to link to the page.

    Thread Starter Francesco Canovi

    (@thedarkmist)

    mmm, ok. That’s not so strong. If you change a slug, the link is going to broke. Anyway, if there are no better solutions, it can work.
    Thank you!

    Typically people don’t change page names all to often if ever. If you ever do change the page name all you have to do is go into the menu and make a simple edit.

    also, for reference, when WP 3.1 comes out, you no longer need to use the page templates. You just need to use the new has_archive feature and you have a list of all posts in the CPT

    With WP 3.1 using has_archive is good…

    I still prefer creating a page and then apply the archive template (or a custom template) to the page, and putting the page in the menu. This way you retain the permalink rewriting and such… it’s just a little more robust than the custom link method.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘CPT list as category in WP custom menu’ is closed to new replies.