I create my own theme with wordpress.
I created a post list page with archive.php, but I would like to solve the problem of clicking on the category link of the article but not going to the category list.
Created an article listing page with archive.php.
When you click on a category for a contributed article, all articles are displayed regardless of category (the URL shows the category).
If you click on the category of new articles (e.g., "cat") displayed on the Article List page, you will want to see a list of only the articles that have the category set by cat.
<?php get_header();?>
<section>
<div class="diary-h"><h2>Diary listing</h2><div>
<?php
global$post;
$args=array('posts_per_page'=>50);
$myposts=get_posts($args);
foreach($myposts as$post){
setup_postdata($post);
?>
<div class="diary-item">
<div class="diary-img">
<?php the_post_thumbnail('index_thumbnail');?>
</div>
<div class="diary-text">
<div class="diary-time">
<?php the_time('Y.m.d')?>
</div>
<div class="diary-category">
<?php the_category(', ')?>
</div>
<div class="diary-title">
<a href="<?php the_permalink();?>">?php the_title();?>/a>
</div>
</div>
</div>
<?php
}
wp_reset_postdata();
?>
</section>
<?php get_footer();?>
<?php get_sidebar();?>
Create category - 〇 ..php by category and obtain each
That's how it was solved!
Thank you to everyone who viewed it!!
© 2024 OneMinuteCode. All rights reserved.