• I’ve done a lot of searching for this and I’ve tried category templates,w which oddly do not work. Category templates are purposefully overridden in this theme…? (Category-id, etc)… I’m not a programmer but I can tinker some so here’s my solution (which so far has worked perfectly) to add category featured images with post excerpts. FOR CATEGORIES. NOT INDIVIDUAL POSTS.

    Ascetica natively supports gallery post type thumbnails. Not for regular posts on category archives. To add that support, do this…

    1. First activate the child theme if you are not using it already.
    2. Move archive.php into the child theme folder.
    3. Open content-gallery.php from the parent theme folder.
    4. Copy the following code for featured thumbnails:
      <?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'singular-gallery-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'default_image' => get_template_directory_uri() . '/images/singular_gallery_thumbnail_placeholder.png', 'width' => 400, 'height' => 230 ) ); ?>
    5. Paste the code in archive.php in your child theme where you want the featured image per post to show up. I paste mine after the title, but before the excerpt. Like this:

      <?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>

      <?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'singular-gallery-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'default_image' => get_template_directory_uri() . '/images/singular_gallery_thumbnail_placeholder.png', 'width' => 200, 'height' => 150 ) ); ?>

    6. Save, close, upload archive.php over the current one.
    7. Now go to style.css in the child theme. Paste this CSS (same CSS as applied for gallery featured images):
      .singular-gallery-thumbnail { float: left; width: 60.60606060606061%; margin:0 30px 30px 0; }

      @media only screen and (max-width: 767px) {
      .singular-gallery-thumbnail { width: 100%; float:none;}
      }

      The @media version is responsive for smart phone screens.

    8. Save, close, upload style.css over the current one in the child theme.

    The featured images should now work correctly in your site. And since the featured images apply a conditional PHP statement for if they exist, there won’t be odd gaps on any posts that may not have an attributed featured image.

Viewing 1 replies (of 1 total)
  • Thread Starter iceytina

    (@iceytina)

    Oh there is one thing I forgot to go over… a BIG step actually…! So sorry — it’s about 12 at night when I wrote this and I’m quite tired…

    Copy this code from content.php (it already has the featured thumbnail added):


    <div id="post-<?php the_ID(); ?>" class="<?php hybrid_entry_class(); ?>">

    <?php do_atomic( 'open_entry' ); // ascetica_open_entry ?>

    <?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>

    <?php if ( current_theme_supports( 'get-the-image' ) ) get_the_image( array( 'meta_key' => 'Thumbnail', 'size' => 'singular-gallery-thumbnail', 'link_to_post' => false, 'image_class' => 'featured', 'default_image' => get_template_directory_uri() . '/images/singular_gallery_thumbnail_placeholder.png', 'width' => 400, 'height' => 230 ) ); ?><?php echo apply_atomic_shortcode( 'byline', '<div class="byline">' . __( '[entry-published] · by [entry-author] · in [entry-terms taxonomy="category" before=""] [entry-edit-link before=" · "]', 'ascetica' ) . '</div>' ); ?>

    <?php the_excerpt(); ?>

    <?php wp_link_pages( array( 'before' => '<p class="page-links">' . __( 'Pages:', 'ascetica' ), 'after' => '</p>' ) ); ?>

    <?php do_atomic( 'close_entry' ); // ascetica_close_entry ?>

    </div><!-- .hentry -->

    Open archive.php and find this line:


    <?php get_template_part( 'content', ( post_type_supports( get_post_type(), 'post-formats' ) ? get_post_format() : get_post_type() ) ); ?>

    Delete it and paste the long above code in it’s place.
    Save, close, upload, refresh page. Should work fine.

Viewing 1 replies (of 1 total)
  • The topic ‘Solution: Add Category Featured Images’ is closed to new replies.