How to let wordpress display all article categories on a separate page?
1. Copy a page.php file and change it to page-abc.php, and create a new page in the WordPress background. Change the fixed link address to abc (this abc can be optional, but it must be with page- abc corresponding).
2. Find the following code in this page-abc.php file:
<?php the_content(); ?>
Related recommendations: "WordPress Tutorial"
and add it in the Add the following code after the code:
<?php $cats = get_categories(); foreach ( $cats as $cat ) { query_posts( 'showposts=10&cat=' . $cat->cat_ID ); ?> <h3><?php echo $cat->cat_name; ?></h3> <ul class="sitemap-list"> <?php while ( have_posts() ) { the_post(); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php } wp_reset_query(); ?> </ul> <?php } ?>
Remember to save and update the page-abc.php file.
At this point, let’s refresh the newly created abc page below to see if articles under all categories have been displayed? The above code displays 10 articles in each category by default. If you need to display all articles, just change the 10 in the code to 1000 or a larger value.
The above is the detailed content of How to display all articles in WordPress on one page. For more information, please follow other related articles on the PHP Chinese website!