• Resolved iu7489

    (@iu7489)


    How can I make custom template files for specific categories or pages with eStar?

    I am referring to the WordPress template hierarchy here: https://developer.ww.wp.xz.cn/themes/basics/template-hierarchy/

    I usually don’t have an issue with it on other themes I’ve tried, but eStar (although lovely) has so many template parts it’s making me quite lost.

    I am looking to make things along the line of page-{slug}.php, single-{post-type}.php, archive-{post_type}.php, category-{slug}.php, and tag-{slug}.php

    Right now I am accomplishing something similar – but very poorly – with a child theme and a lot of conditional statements. 👀🙈

    I feel it should be easier to accomplish. Am I missing something?
    Can you please help point me in the right direction?

    Thanks.

Viewing 1 replies (of 1 total)
  • Theme Author GretaThemes

    (@gretathemes)

    Hi @iu7489

    Thanks for your question.

    We realize this is also a problem we have to resolve in future updates.

    First at all, I’ll for example guide you to create custom template for category. Create category-{slug}.php and copy the entire contents of archive.php file (template-part/archive.php)

    
    <?php
    get_header();
    ?>
    
    <main class="main" role="main">
    	<?php if ( have_posts() ) : ?>
    		<?php get_template_part( 'template-parts/archive-header' ); ?>
    
    		<div class="entries abcdef">
    			<?php
    			while ( have_posts() ) {
    				the_post();
    
    				$layout = get_theme_mod( 'archive_content_layout', 'list-horizontal' );
    				$layout = in_array( $layout, ['grid', 'grid-card'], true ) ? 'grid' : 'list';
    				get_template_part( 'template-parts/content/archive', $layout );
    			}
    			?>
    		</div>
    
    		<?php the_posts_pagination(); ?>
    	<?php else : ?>
    		<?php get_template_part( 'template-parts/content/none' ); ?>
    	<?php endif; ?>
    </main>
    
    <?php
    get_sidebar();
    get_footer();
    
Viewing 1 replies (of 1 total)

The topic ‘Template hierarchy and customization’ is closed to new replies.