Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9096101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:45:55+00:00 2026-06-16T23:45:55+00:00

i have created custom post type ‘event’ to display in single page named single-event.php

  • 0

i have created custom post type ‘event’ to display in single page named single-event.php file but it provides me 404 error. how i can solve this problem even i used

flush_rewrite_rules();

Please help me to solve my problem… here is my code..

function custom_event() {
$labels = array( 
'name' => _x('Event', 'post type general name'),
'singular_name' => _x('Event', 'post type singular name'),
'add_new' => _x('Add Event', 'Content'),
'add_new_item' => __('Add New Event'),
'edit_item' => __('Edit Event'),
'new_item' => __('New Content'),
'view_item' => __('View Event'),
'search_items' => __('Search Content'),
'not_found' =>  __('Nothing found'), 
'parent_item_colon' => '',
'menu_name' => __('Event')
 );

 $args = array(
 'labels' => $labels,
 'public' => true,
 'publicly_queryable' => true,
 'show_ui' => true, 
 'show_in_menu' => true,  
 'query_var' => true,
 'rewrite' => true,
 'capability_type' => 'post',
 'has_archive' => true, 
 'hierarchical' => false,
 'menu_position' => 20,
 'supports' => array( 'title', 'editor')
  );

  flush_rewrite_rules();
  register_post_type('event', $args); 
  }
  //$wp_rewrite->flush_rules();
  //add_action('admin_init', 'flush_rewrite_rules');
   add_action ('init', 'custom_event');
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:45:56+00:00Added an answer on June 16, 2026 at 11:45 pm

    Try using 'rewrite' => array( 'slug' => 'event' ) instead of 'rewrite' => true.

    Also, you shouldn’t use flush_rewrite_rules() like this. It will run unnecessarily each time. You could make a plugin to define the custom post type and flush the rewrite rules using register_activation_hook.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom post type named People. I have created a page
I have a WordPress custom post-type setup. I've created single-[customposttype].php However instead of displaying
i have created a custom post type named Books & i have a widget
I have created a custom post type of 'portfolio' and page with a template
I have created a custom post type for my portfolio page. I have two
I have created custom post types called Internal products I Have a page page-internal-products.php
I have created a custom post type restaurant. But Its not coming on the
Good morning... I have created a custom post type called Testimonials. To display them,
I have created Custom slideshow post type.Images set as featured images for each new
I have created a custom post type called banners and want to enable the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.