Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have created a custom post type and I want to link directly to some of the posts in the custom post type in my main navigation menu.

I can see the posts in the left hand side of the menu page, and can add the posts to my main menu, however the link does not appear in the frontend of the website after saving.

After saving the link is still there in the menu view in the admin panel.

Here are the labels and arguments I pass to the register_post_type function:

public $labels = array(
    'name'               => 'Special Offers',
    'singular_name'      => 'Special Offer',
    'add_new'            => 'Add New Special Offer',
    'all_items'          => 'All Special Offers',
    'add_new_item'       => 'Add New Offer',
    'edit_item'          => 'Edit Offer',
    'new_item'           => 'New Offer',
    'view_item'          => 'View Offer',
    'search_items'       => 'Search Special Offers',
    'not_found'          =>  'No Offers found',
    'not_found_in_trash' => 'No Offers found in trash',
    'parent_item_colon'  => 'Parent Offer:',
    'menu_name'          => 'Special Offers'
);

public $args = array(
    'description'         => "",
    'public'              => true,
    'exclude_from_search' => false,
    'publicly_queryable'  => true,
    'show_ui'             => true, 
    'show_in_nav_menus'   => true, 
    'show_in_menu'        => true,
    'show_in_admin_bar'   => true,
    'menu_position'       => 26,
    'capability_type'     => 'post',
    'hierarchical'        => false,
    'supports'            => array('title','editor','thumbnail'),
    'has_archive'         => true,
    'query_var'           => true,
    'can_export'          => true,
    'rewrite'             => array('slug' => 'specialoffers')
);

Everything else works perfectly with my custom post type.

Please can anyone suggest a way to make the custom post type links appear in my main menu, or diagnose the problem for me?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The answer was very simple, I was accidentally adding my register_post_type() function within an is_admin() condition, therefore on the public facing side of the website the post type was never registered, hence it not showing up.

share|improve this answer
    
Glad you figured it out and thanks for posting your answer. +1. Just on that, this is why it is always important to post as much code that is directly relevant to your question. This could have been sorted within a couple of minutes :-) Enjoy –  Pieter Goosen Aug 11 at 14:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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