WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a custom post type "events" to display event information. All links to the events work well when I am logged in. However, if I am not log in, all the links for events that set in the future are broken - having a page not found message; but these pages will display as soon as I log in. -- all links for events in the past are working well no matter log in or not.

Please advice what cause the problem and how to fix it.


I have the following code in the functions.php in my child theme:

function enable_event_posttype() {
    register_post_type( 'events',
            'labels' => array(
                'name' => __( 'Events' ),
                'singular_name' => __( 'Event' ),
                'add_new' => __( 'Add New Event' ),
                'add_new_item' => __( 'Add New Event' ),
                'edit_item' => __( 'Edit Event' ),
                'new_item' => __( 'Add New Event' ),
                'view_item' => __( 'View Event' ),
                'search_items' => __( 'Search Event' ),
                'not_found' => __( 'No events found' ),
                'not_found_in_trash' => __( 'No events found in trash' )
            'public' => true,
            'scheduled' => true,                 
            'supports' => array( 'title', 'editor', 'comments'),
            'capability_type' => 'post',
            'rewrite' => array("slug" => "events"), // Permalinks format
            'menu_icon' => get_bloginfo('stylesheet_directory') . '/images/date.png',  // Icon Path
            'menu_position' => '5'

add_action( 'init', 'enable_event_posttype' );
share|improve this question
how are you storing event dates? post dates in the future are scheduled, not published, so aren't publicly visible until that date. the way to handle this is to store the event date as meta data rather than use the publish date. – Milo Feb 26 '13 at 15:42
Please post relevant code; otherwise, the question is impossible to answer. – Chip Bennett Feb 26 '13 at 15:47
I have the following code in the function.php in my child theme: – Lisha Feb 26 '13 at 15:59
sorry, the code is too long to be added here, so I have added it at the end of the question. – Lisha Feb 26 '13 at 16:06
Hi Milo, thanks, and yes, I store the event dates in the post dates, and set the visibility to Public, and the status to Scheduled. Please advice in more detail how to handle it using meta data as I don't know much about it. – Lisha Feb 26 '13 at 16:15
up vote 0 down vote accepted

I would recommend downloading the excellent Advanced Custom Fields plugin and using that. It will let you easily create a field to accept a date and it uses a date picker to ensure you are getting the proper format stored.

Then, in your code, all you have to do is this: echo get_field('event_date'); ... assuming you named your field event_date.

There is a lot more you can do with the plugin, but it would definitely help you in this case.

share|improve this answer

Your Answer


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.