0

I am generating a navigation menu on my website using the wp_list_pages() function and I also am using a couple of custom post types with a post type archive function. How would I go about adding a link to the wp_list_pages function to also include a link to my post type.

The menu is as follows:

Home
Tour & Arrival Information
Getting Around
About Us
Contact Us

These are all pages and as such, are automatically found and placed into the list_pages function. I have a custom post type called sponsors which is a page that lists sponsors of the site.

How do I add a link to /sponsors? Can you make Wordpress treat a custom post type as a page and link to it? I did try and use the Wordpress menus functionality, but it couldn't see my post type.

I understand that the wp_list_pages uses internal functions to get pages with the post type of 'page' and that I need to use another function to accomplish what I am trying to do, however, I am stuck.

I don't want to display posts using the post type 'sponsors' I just want to display a link to /sponsors that says sponsors, but allow the client to rearrange the order of the navigation which leads me to believe that I need to use a menu.

Sorry if I didn't provide enough information, just ask if I didn't. I'm very busy at present and probably didn't describe myself properly.

2 Answers 2

2

You're not able to classify a custom post type as a page, because as the name itself states, it s a custom post type (therefore not a page).

In your case, and for making the management of your menu(s) easier in the future, I would strongly recommend that you add a 'Menu' to your theme.

  1. First Make sure you are using Wordpress 3.0 or later.
  2. Secondly, follow this easy tutorial to add a Menu to your theme.
  3. Lastly, you will be able to create a menu using the interface found in Appearance > Manus and items to it as you please.

Well I hope that did the trick for you! Let me know how it goes.

2
  • Hi Michal, a menu is definitely the way to go. However, how can I have a link in my menu to the custom post type and also have the flexibility of having a selected state on the nav? I kind of need to apply a class of current for the current page, the wp_list_pages function applies a class of 'current_page_item' to the current element, can menus support this? Commented Feb 16, 2011 at 2:09
  • The nav menu system adds active classes as appropriate, Justin's blog here covers menu usage in more depth: justintadlock.com/archives/2010/06/01/…
    – t31os
    Commented Feb 16, 2011 at 11:32
1

I solved this issue a different way. I created a page called 'sponsors' and then created a custom page template that ignored any content entered into the editor and used some custom Wordpress queries to get content from my custom post type. It's so simple and works so well as well.

The benefit is I have a page that is merely a proxy for other content and the menu order can be adjusted as if it were a normal page (well, it is).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.