How to display title and featured image only when category is chosen

On my blog, harpoon71.com/blog, I want to display all posts under a category, and sub-categories, as a title and featured image only. I don't want to use the 'more' feature, just title and image only.

In the code please assume the category is name 'camping'.

I am using TwentyFifteen theme and have made a child theme.

Due to being a complete novice can you tell me which file I should be looking in.

Thanks

Topic theme-twenty-fifteen Wordpress

Category Web


I found the answer (well I paid for it) so I am sharing it here.

This code only display the title and featured image for a chosen category and sub-categories.

I made a child theme and created a new content.php file. Then I used the following code. Look for //Here use the id of the category then add your own category ID (replace 14).

Sorry I don't know how to enter code properly on this site.

" >

', '' ); else : the_title( sprintf( '', esc_url( get_permalink() ) ), '' ); endif; ?> $category_id ) ); $array_cats=array(); foreach($categories as $cat){ $array_cats[]=$cat->term_id; } $array_cats[]=$category_id; if(!has_category($array_cats)){ ?> ', '', false ) ) );

wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyfifteen' ) . '', 'after' => '', 'link_before' => '', 'link_after' => '', 'pagelink' => '' . __( 'Page', 'twentyfifteen' ) . ' %', 'separator' => ', ', ) ); ?>

', '', false ) ) );

wp_link_pages( array( 'before' => '' . __( 'Pages:', 'twentyfifteen' ) . '', 'after' => '', 'link_before' => '', 'link_after' => '', 'pagelink' => '' . __( 'Page', 'twentyfifteen' ) . ' %', 'separator' => ', ', ) ); ?>

', '' ); ?>


The file you are looking for is content.php.

You can find more informations about Template hierarchy here: https://developer.wordpress.org/themes/basics/template-hierarchy/

The sections you have to get rid of are the divs:

<div class="entry-content"> ... ... </div>

<div class="entry-footer"> ... ... </div>

So you have many ways to achieve it, the simpler is to clone the file in your child theme, then wrap these divs in an IF statement like the example below, in order to check if the current page is a category or not:

if( !is_category() ):

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.