Support » Theme: Quark » Custom Post Type Archive Pages

  • Resolved fcarlini

    (@fcarlini)


    Hey,

    To start with, great theme starter theme. Very nice and clean.

    I’ve recently created a custom post type for the theme and it’s working great. The only issue I have found, is unlike in other themes, when I create a custom post type I am able to create a custom archive page.

    This theme will only recognize if I create an archive.php page and that works great… but what happens if I have 2 custom post types (so you can see the problem I am having).

    If I create for example an ‘archive-portfolio.php’ for it doesn’t recognize it and just shows it like your post-archives.php page.

    Does this theme not allow for it? Am I doing something wrong? I’ve checked the code multiple times and have tried multiple suggestions on the web, to no avail.

    Your help would be appreciated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Theme Author Anthony Hortin

    (@ahortin)

    When you create Custom Post types…

    – Single posts of a custom post type will use single-{post_type}.php
    – and their archives will use archive-{post_type}.php

    You can learn more about using Custom Post Type templates here…
    http://codex.wordpress.org/Post_Types#Custom_Post_Type_Templates

    Thread Starter fcarlini

    (@fcarlini)

    So that’s the thing. I did that for the archive, and it’s not working. It brings up the regular post archive.

    I’ve done it multiple times checking everything with no positive results.

    Theme Author Anthony Hortin

    (@ahortin)

    I just created a new custom post type, called ‘movie’, using a clean install of Quark and a Quark Child theme.

    I then copied index.php from the Quark parent theme and added it to the root of my child theme, renaming it to archive-movie.php.

    After adding some dummy data, I then added the following debug code to the bottom of my functions.php file, which displays the currently used template name, to confirm that it was indeed using the correct archive template.

    /**
     * Debug function to show the name of the current template being used
     */
    function show_template() {
       global $template;
       print_r($template);
    }
    add_action('wp_head', 'show_template');

    This all worked fine and my new Custom Post Type did use the correct archive template (archive-movie.php). When I removed this template, the archive page reverted back to using index.php, as expected.

    Theme Author Anthony Hortin

    (@ahortin)

    One thing that you might also want to do, is to resave your Permalinks (SETTINGS > PERMALINKS). Sometimes your new Custom Post Types wont display correctly until you resave your permalinks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Post Type Archive Pages’ is closed to new replies.