• Resolved ilmattiapascal

    (@ilmattiapascal)


    hi guys, i m making a twentytwelve child theme,

    i changed my content.php for the main page, and now i would like to have the same effect in the category page.

    /* Start the Loop */
    			while ( have_posts() ) : the_post();
    
    /* Include the post format-specific template for the content. If you want to this in a child theme then include a file called content-___.php (where ___ is the post format) and that will be used instead.
    */
       get_template_part( 'content', get_post_format() );
    
    endwhile;
    
    twentytwelve_content_nav( 'nav-below' );
    ?>

    this is what is written in the code of the category.php

    i swear i can’t understand what WP tells me about the template. What i ve to put instead of ____ ? my file is called content.php and has his own new template, but i still see a different template in the category page.

    thanks in advance!

Viewing 11 replies - 1 through 11 (of 11 total)
  • content.php is the file that is still being used in category pages.

    Thread Starter ilmattiapascal

    (@ilmattiapascal)

    yes, but i want to have the featured image of the posts also in the category page like in the main page. My cateogry page shows only the post title with excerpt, but not the featured image, and i really don’t know what and where i should work.

    You need to edit your child’s copy of content.php

    i changed my content.php for the main page

    what is the full code of your changed template?
    please use the pastebin – https://codex.www.ads-software.com/Forum_Welcome#Posting_Code

    Thread Starter ilmattiapascal

    (@ilmattiapascal)

    <header class="entry-header">
    
    		<span class="category-title">
    		<?php foreach( get_the_category() as $category ) {
    		$category_name = $category->cat_name;
    		}
    		echo ' <a href="' . get_category_link( $category->term_id ) . '">' . $category_name . '</a> ';
    			?>
    		</span>
    
    			<?php if ( is_single() ) : ?>
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<?php else : ?>
    			<h1 class="entry-title">
    				<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    			</h1>
    			<?php endif; // is_single() ?>
    
    		</header><!-- .entry-header -->
    
    		<?php if( is_home() && $wp_query->current_post != 0 || is_home() && is_paged() ) the_post_thumbnail(); ?>
    
    		<?php if ( is_search() || is_archive() || is_category() || is_tag() || is_home() ) : // display Excerpts ?>
    
    		<div class="entry-summary">
    			<?php the_excerpt(); ?>
    			<a href="<?php echo get_permalink(); ?>"> Read More...</a>
    		</div><!-- .entry-summary -->
    		<?php else : ?>
    		<div class="entry-content">
    			<?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentytwelve' ) ); ?>
    			<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
    		</div><!-- .entry-content -->
    		<?php endif; ?>
    
    			<footer class="entry-meta">
    
    			<?php
    				$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
    					esc_url( get_permalink() ),
    					esc_attr( get_the_time() ),
    					esc_attr( get_the_date( 'c' ) ),
    					esc_html( get_the_date() )
    			);
    			echo $date ;?>
    
    				<?php if ( comments_open() ) : ?>
    
    					<?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentytwelve' ) . '</span>', __( '1 Reply', 'twentytwelve' ), __( '% Replies', 'twentytwelve' ) ); ?>
    
    			<?php endif; // comments_open() ?>
    			</footer>

    this is the content.php code

    i modified the position of some stuff, and first of all, thanks to you alchymyth, i was able to place a big image for the first post of the main page. (the query string)

    the home page has a big image as featured image only for the first post, for the others has simply the featured image smaller.

    from the menu you can access to different links which are categories. For example i ve a category called illustrations. From the menu i click illustrations and i will find a page with all the illustration category posts. The problem is that the list of posts doesn’t have the featured image. I don’t even want this to be like the main page with the big image for the first post; i only need a simple post list with featured images for each post.

    Thread Starter ilmattiapascal

    (@ilmattiapascal)

    ah of course, the code isn’t the whole template, but i thought it was the most important part ?? and the menu is nothing else than the navigation bar.

    The problem is that the list of posts doesn’t have the featured image.

    this line restricts the post thumbnail to the posts page:

    <?php if( is_home() && $wp_query->current_post != 0 || is_home() && is_paged() ) the_post_thumbnail(); ?>

    to have the featured image to show in category archive pages as well, change it to:

    <?php if( ( is_home() || is_category() ) && $wp_query->current_post != 0 || ( is_home() || is_category() ) && is_paged() ) the_post_thumbnail(); ?>

    or to have that in all archives, replace is_category() with is_archive()

    Thread Starter ilmattiapascal

    (@ilmattiapascal)

    thanks alchymiyth it worked well, but it still has a problem. The featured image now it’s ok with all the post of the category except the first. That’s probably because we made together some months ago that trick that let me show a really big featured image for the first post of the home.
    So maybe the problem is on that wpquery–>current post !=0 ?

    i ve another short question for you; how and where i can change the fact that the category.php file takes information from content.php? i just would like to make another content.php file, called for example, content-cat.php and let the category.php take information from it.

    thanks again for your patience,

    <?php if( is_home() && $wp_query->current_post != 0 || is_home() && is_paged() || is_category() ) the_post_thumbnail(); ?>

    how and where i can change the fact that the category.php file takes information from content.php?

    in category.php in the line with get_template_part( 'content', ....)

    https://codex.www.ads-software.com/Function_Reference/get_template_part

    Thread Starter ilmattiapascal

    (@ilmattiapascal)

    great. Thank you alchymyth, see u to the next problem. I ve nearly completed my blog so i ll not stress you too much anymore. Maybe i need only to change the layout in that category section with a custom content-cat.php file for categories with a new style.css layout..if i ll ve problems i ll write.

    anyway, thanks again!

    Thread Starter ilmattiapascal

    (@ilmattiapascal)

    solved

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘How do i put the content template in the category page ?’ is closed to new replies.