cqde
cqde

Reputation: 331

WordPress - Custom Post Type Entry Won't Load Into A Page

I created a very basic custom post type in my WP site to hold events. Basically, a user can input an event title, some information about the event and the date.

Currently, the only time the events are being displayed are in my sidebar where I just pull the title and date of the upcoming events.

However, I want to be able to allow the user to also click on the title of the link to lead to the event's individual page. I tried previewing my custom post type event and it kept leading me to my 404.php page. The events don't seem to load into a page at all.

I'm hoping this is a small property that I didn't set when I registered my post type. Any help?

Upvotes: 0

Views: 1166

Answers (2)

10SexyApples
10SexyApples

Reputation: 21

Wordpress has incorporated custom post types into the template hierarchy and you have access to them at single-$posttype.php and archive-$posttype.php.

If you create these templates and your posts don't show up in the loop, you need to reset your permalinks/flush your rewrite rules.

As well, it would help to see how you are registering your post types, as in order for your archive-$posttype.php to be available you need to call has_archive => true in your arguments.

Upvotes: 2

Rochester Oliveira
Rochester Oliveira

Reputation: 1483

What i've done when i needed it:

Add this code in the same function that create your post type:

add_action("template_redirect", array(&$this, 'template_redirect'));

function template_redirect() {
        global $wp;
        if ($wp->query_vars["post_type"] == "events")
        {
            include(TEMPLATEPATH . "/events.php");
            die();
        }
    }

Then, just create events.php with the_loop (like single.php)!

Hope it helps

[]'s

Upvotes: 0

Related Questions