WordPress.org

Ready to get started?Download WordPress

Forums

Facing 404 while creating custom post template (5 posts)

  1. Tarun Kumar
    Member
    Posted 2 years ago #

    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.

  2. s_ha_dum
    Member
    Posted 2 years ago #

    What is your URL?
    What are your $args?

  3. Tarun Kumar
    Member
    Posted 2 years ago #

    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 http://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.

  4. s_ha_dum
    Member
    Posted 2 years ago #

    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.

  5. Simon Wheatley
    Code for the People
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic