0

I have created a custom post type and registered it using this code

$labels = array(
  'name' => __( 'Portfolio' ),
  'singular_name' => __( 'Portfolio' )
);

$args = array(
  'labels' => $labels,
  'public' => true,
  'exclude_from_search' => false, 
  'publicly_queryable' => true,
  'show_ui' => true, 
  'query_var' => true,
  'capability_type' => 'post',
  'hierarchical' => false,
  'menu_position' => null,
  'supports' => array('title','editor','thumbnail','custom-fields', 'page-attributes', 'excerpt', 'revisions'),
  'show_in_nav_menu' => true
);
register_post_type('portfolio',$args);

I can create a portfolio post type and save it. It all works as expected until I go to Appearance > Menus where I can add the portfolio to the menu but it wont show up in the index template using this code

wp_nav_menu(array('theme_location'=>'main_menu'));

All the other menu items show properly just not the custom post types. If you look at the screenshot, all that is shown in the front end is 'Shortcodes' link and 'BBC' link (so page and custom link - not portfolio link)

Help! I need those links in there.

Screenshot of Appearance > Menus here

screenshot

1

Add a s to show_in_nav_menu : show_in_nav_menus

  • soju, I was very excited when I saw this and tried it. I deleted all the posts and started again with this in. No change. Still nothing. – sl1nky Apr 18 '12 at 11:00
0

First you need to add the following to your $arg array

'rewrite' => array('slug' => 'portfolio')

Then you will need to create a page in wordpress admin called 'Portfolio' or any other title but as long as the page slug is 'portfolio'. Publish it.

Then go to the Appearance>Menus and add the page to your menu. Go to the frontend and go to the link in your menu and if you have any posts there you'll see a list of them - otherwise it will say that nothing has been found.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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