• My goal is to have a thumbnail-based archive page which shows only the thumbnail and the post title in a grid on a separate archive page.

    I am working on the spacious theme and already set up a child theme. Spacious already has a built-in archive.php but I couldnt chose it as template in the dashboard therefore I created a new file called archive-page.php in the child folder shich is an exact copy of the archive.php file and which I can adjust with the following code in it:

    <?php
    /*
    Template Name: page-archive
    */
    ?>

    <?php get_header(); ?>

    <?php do_action( ‘spacious_before_body_content’ ); ?>

    <div id=”primary”>
    <div id=”content” class=”clearfix”>

    <?php if ( have_posts() ) : ?>

    <?php while ( have_posts() ) : the_post(); ?>

    <?php if ( has_post_thumbnail()) : ?> ” title=”<?php
    the_title_attribute(); ?>” >
    <?php the_post_thumbnail(thumbnail, array(‘class’ => ‘alignleft’)); ?>

    <?php endif; ?>

    <?php get_template_part( ‘content’, get_post_format() ); ?>

    <?php endwhile; ?>

    <?php get_template_part( ‘navigation’, ‘archive’ ); ?>

    <?php else : ?>

    <?php get_template_part( ‘no-results’, ‘archive’ ); ?>

    <?php endif; ?>

    </div><!– #content –>
    </div><!– #primary –>

    <?php spacious_sidebar_select(); ?>

    <?php do_action( ‘spacious_after_body_content’ ); ?>

    <?php get_footer(); ?>

    Now I can chose the archive template in the page section of the dashboard but of course it does not show the archive in the way I want it. Can someone help me with how I have to adapt the code (php) to make appear the thumbnails?

    I would be very thankful for every help available (also links to tutorials or code snippets…)!
    Thank you!

Viewing 1 replies (of 1 total)
  • Hello calliebine,

    Well done on the code above. I think you issue is probably coming from naming file.

    WordPress will look for archive.php when showing archive pages. If you would like to use your code for all archives on the site, then you would just put your code in the archive.php file in your child theme.

    If you are trying to show the thumbnail based archive for one category only, then you should append the category slug or id to that php file.

    For instance, if you have a category books. the archive.php you create can be called category-books.php or category-42.php (if 42 if the id of that category.)

    Have a look at the support pages here and see if it explains it any further.

    Let me know how you get on.
    Drew

Viewing 1 replies (of 1 total)

The topic ‘Spacious Theme – thumbnail based archive page’ is closed to new replies.