• Hi

    The codex says the archive page for a custom post type should be:
    archive-{post_type}.php
    I have a archive for resources: https://tsa.thedesignweb.com.au/resources/ which is using the archive.php template

    I have tried creating archive-resources.php to make some changes, but it won’t read for the new template.

    From firebug in body class I see template post-type-archive-resources.php, but even when I create one and call it this it won’t work.

    Any ideas about what am I doing wrong?

    Thanks.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi Belinda,

    You could try installing the What Template plugin to see which one it’s using.

    Thread Starter belindajohnstone

    (@belindajohnstone)

    Thanks! (I said hi at WP Sydney, at the checink table)

    The plugin is handy. Works for most pages, but the theme uses a template called base.php, so it doesn’t help with any archive pages.
    I did manage to get the archive page working with archive.php though, was weird, I tried using index.php and changing the name,instead of archive.php and it worked, and now both work. Mysterious.

    Now trying to figure out the taxonomy. I have one called geography, with a whole lot of locations, is it possible to get a listing for the taxonomy name, that lists all the resources filed under locations added under it?

    Thanks again!

    Ah! Hello again, yes I remember!

    Yes, that’s certainly possible. So geography is a tax and resources is a CPT?

    In your taxonomy-geography.php template:

    <?php
    $queried_object = get_queried_object();
    $args = array(
    	 'post_type' => 'resources',
    	 'geography' => $queried_object,
    );
    $show_posts = get_posts( $args );
    foreach ( $show_posts as $post ) : setup_postdata( $post );
    ?>
    <!-- html goes here -->
    
    <?php endforeach; wp_reset_postdata(); ?>
    Thread Starter belindajohnstone

    (@belindajohnstone)

    Hey, thanks so much for your reply.

    The virtue premium theme has so many options built in that the code and is way to complicated! I think I’ll stick to plugins on this one. Just need to find one where I can sort by multiple taxonomies.
    Cheers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Archive template for custom post types’ is closed to new replies.