Home > CMS Tutorial > WordPress > How to display all articles in WordPress on one page

How to display all articles in WordPress on one page

爱喝马黛茶的安东尼
Release: 2019-07-25 11:47:18
Original
3979 people have browsed it

How to display all articles in WordPress on one page

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(); ?>
Copy after login

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( &#39;showposts=10&cat=&#39; . $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 } ?>
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template