• Hi,
    I am getting 404 template not found error while trying to view custom post type. What all I have done is

    Step 1: Register new post type using register_post_type(‘tour_package’,$args);

    Step 2 : Define rewrite value for my custom post type
    $args = array(

    ‘rewrite’ => array(“slug” => “tourpackage”),
    ….. );

    Step 3: Created a tour package template file in the themes directory naming single-tourpackage.php.

    Now when I create a tour package from the admin ui, it gets saved properly as expected but when I click on view link against the tour package, I get 404 error.

    Please help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • What is your URL?
    What are your $args?

    Thread Starter Tarun Kumar

    (@thinkertarun)

    Hi s_ha_dum,

    Thanks a lot for prompt help, my apologies for delay at my end due to net connectivity issue.

    Url of the post is https://localhost/mytoursite/tourpackage/agra/
    where tour package is custom post type name and agra is title of my post.

    One thing which I noted while executing wordpress in debug mode that the post type returned by get_post_type function for this is post while in database post table it shows post type as tourpackage the one I defined in slug.

    Well a ‘localhost’ address isn’t going to help since your site isn’t on my computer. ?? Make it harder.

    It is hard to tell what you’ve done. Paste your code for the custom post type to the pastebin, please– all of it.

    Step 3: Created a tour package template file in the themes directory naming single-tourpackage.php.

    Try single-tour_package.php, the format of the template filename for the single of a custom post type is single-post_type_name.php.

    Hope this helps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Facing 404 while creating custom post template’ is closed to new replies.