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