Edit This has been resolved. See the cause and resolution below.

Edit: this may offer an important clue. When I'm logged in as the admin, the links work fine, but when I'm logged out I get the 404 error.

Before posting I tried almost every suggestion from searching StackExchange and google.

Overview: When I enter the permalink of a post it returns a 404. When I click on a link created by get_the_permalink(); I will see a 404 and this url structure ?post_type=lunchlearn&p=530 rather than /lunchlearn/burner-start-up-and-tech/

I've tried saving the permalink structure, flush_rewrite_rules, different rewrite rules, etc. Any help would be extremely appreciated.

I have a few custom post types I created within the functions.php. One example is below:

function register_lunchandlearn () {
  // Lunch and Learn post type
  $labels = array(
        'name' => 'Lunch and Learn',
        'singular_name' => 'Lunch and Learn',
        'add_new' => 'Add Event',
        'all_items' => 'All Events',
        'add_new_item' => 'Add Event',
        'edit_item' => 'Edit Event',
        'new_item' => 'New Event',
        'view_item' => 'View Event',
        'search_item' => 'Search Events',
        'not_found' => 'No events found',
        'not_found_in_trash' => 'No events found in trash',
        'parent_item_colon' => 'Parent event'
    $args = array(
        'labels' => $labels,
        'menu_icon' => 'dashicons-welcome-learn-more',
        'public' => true,
        'has_archive' => true,
        'publicly_queryable' => true,
        'query_var' => true,
        'rewrite'               => array( 'slug' => 'lunchlearn', 'with_front' => false ),
        'capability_type' => 'post',
        'hierarchical' => false,
        'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'revisions'),
        'taxonomies' => array('category', 'post_tag'),
        'menu_position' => 5,
        'exclude_from_search' => false,
  • 1
    Looks like your posts are private somehow. Check that first. Also, check whether your permalink setting is post name or not. Also, you seem to be viewing a draft by the look of your URL structure. First, publish a post and check that as well.
    – Bikram
    Commented Mar 3, 2020 at 1:57
  • Bikram - you got me on the right track! I was displaying future posts. I was not aware displaying future posts would only be seen by admins. I decided to use a custom field to choose and sort by date. (In this case posts are events.) Thanks so much!
    – cesjr02
    Commented Mar 3, 2020 at 16:04

1 Answer 1


This issue has been resolved! I had queried to display future posts, making them only viewable by an admin. I decided to use a custom field date picker to choose and sort by date.

This way my custom post type (which are future help events) can be displayed and sorted.

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.