WordPress.org

Forums

[resolved] Cannot pick up the archive-postype template (8 posts)

  1. I created a custom post type for my testimonials and set up a genre taxonomy for these.

    I can display the links to the various genre and when I click on the link, I do get the testimonials with the correct taxonomy, but it's displaying them using the archive.php template.

    I want to display them differently and so set up a archive-testimonial.php template, but it's just being ignored.

    I tried naming it category-testimonial.php, taxonomy-testimonial.php, but nothing works.

    Here is the link to the testimonials if it helps.

    http://www.leeashley.com/wp/testimonials/

  2. Tyler Sticka
    Member
    Posted 3 years ago #

    Saw your plight on Twitter, thought I might come to the rescue (or at least attempt to).

    Here are my two guesses...

    Firstly, are you setting has_archive in your register_post_type arguments to true?

    Secondly, have you tried calling flush_rewrite_rules() after your register_post_type line?

    If neither of those suggestions are applicable, I think we'll need to see what your register_post_type args look like to provide more assistance.

  3. This is what I have in my function file right now.

    http://pastebin.com/t1bf94ZA

    I'll look and see if I can figure out this flush_rewrite_rule()

  4. Tyler Sticka
    Member
    Posted 3 years ago #

    Yeah, your arguments look fine. I would just insert:

    flush_rewrite_rules();

    After line 62, right after you register your taxonomy. Then, reload your page (so functions.php executes) and see if it works.

  5. There must be something else going on somewhere cause it's still not working...

    Arrrgggg.....

    I've got someone else looking into it though.

  6. Tyler Sticka
    Member
    Posted 3 years ago #

    Sorry to hear that! Maybe one little argument is off.

    One other thing to keep in mind. It's generally considered poor practice to name custom post types without a theme- or plugin-specific prefix. For example, instead of testimonial you'd use bluelime_testimonial and then use the rewrite argument to specify a slug of testimonial.

    If you happened to try any plugins or something else that may have used a similar post type, you can run into some nasty conflicts.

    Now, I doubt that's what's happening here, but it's worth mentioning.

    Best of luck!

  7. I hear you Tyler, I usually have my prefix, but the code that you are seeing now has been changed about 5 times since we've started this thread. I'm trying some code that a twitter follower provided. I'll go and fix it once I have this going.

  8. With the help from Tyler and other twitter friends. I managed to get this working. The Custom Post Type code was updated in the functions.php and I create a taxonomy-genre.php template.

    Here is the code if anyone wants it.

    Code for the CPT - http://pastebin.com/GrcRpCTR

    Code used in my taxonmy-genre.php http://pastebin.com/tW7KZUiN

    Yes, I hardcoded the h1, tsk, tsk...
    Whatever...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags