categories show its own posts and not others
This commit is contained in:
parent
1c91a61880
commit
9110bfe34d
|
@ -30,12 +30,11 @@ endif;
|
|||
<?php
|
||||
// https://codex.wordpress.org/Conditional_Tags
|
||||
if ( is_post_type_archive ( 'archive_resource' ) ) :
|
||||
|
||||
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
|
||||
get_template_part( 'template-parts/section', 'resources', array( 'post_per_page' => '10' ) );
|
||||
|
||||
elseif ( is_category( 'resources' ) ):
|
||||
get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => 'resources', 'post_per_page' => '10' ) );
|
||||
elseif ( is_category( 'news' ) ):
|
||||
// get_template_part( 'template-parts/section', 'categoryposts', array( 'category_name' => 'news', 'post_per_page' => '3' ) );
|
||||
get_template_part( 'template-parts/section', 'categoryposts', array( 'post_per_page' => '3' ) );
|
||||
elseif ( is_category( '' ) ):
|
||||
get_template_part( 'template-parts/section', 'categoryposts', array('post_per_page' => '6' ) );
|
||||
|
||||
|
|
|
@ -12,20 +12,14 @@
|
|||
//https://developer.wordpress.org/reference/functions/get_template_part/#comment-4130
|
||||
// var_dump( $args ); //will display everythin imported from
|
||||
// get_template_part( 'template-parts/section', 'category', array('category_name' => 'news', 'post_per_page' => '3' ) );
|
||||
$thiscategory = $args['category_name'];
|
||||
// $thiscategory = $args['category_name'];
|
||||
$howmanyposts = $args['post_per_page'];
|
||||
?>
|
||||
$thiscategory = esc_html( get_the_category()[0]->name );
|
||||
?>
|
||||
|
||||
<section class="category-posts <?php echo $thiscategory;?> ">
|
||||
<header>
|
||||
<h2>
|
||||
<?php
|
||||
if ( is_category() ):
|
||||
single_cat_title();
|
||||
else:
|
||||
echo $thiscategory;
|
||||
endif;?>
|
||||
</h2>
|
||||
<h2><?php single_cat_title();?></h2>
|
||||
</header>
|
||||
<main class="">
|
||||
<?php $the_query = new WP_Query( array( 'category_name' => $thiscategory, 'posts_per_page' => $howmanyposts ) ); ?>
|
||||
|
@ -70,4 +64,3 @@
|
|||
</nav>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
|
|
Loading…
Reference in New Issue