Have you ever wanted to display popular posts on a page so that website visitors can easily grasp the trending content? If that’s what you’re looking for, we’ll help you do it with specific instructions in today’s blog. We are here to bring you 3 methods to display WordPress list posts on a page. They are using a plugin, shortcode, and a custom template. So, all you need to do is explore the following guides and choose the most suitable one to implement for your site. Now, let’s take a look!
Three methods to display WordPress List Posts
Using shortcode plugin
First of all, you need to install the Display Posts plugin – one of the most useful WordPress Popular Post Plugins. Now, on the admin dashboard, let’s access Plugins -> Add New, then enter the name of the plugin on the search bar.
After that, choose the first plugin, click on the Install Now -> Activate button.
The next step you need to do is go to Pages -> Add New to generate a new page with an optional title. In the image below, we enter Archives for the title box. Then, you simply add the following shortcode to the page:
[display-posts posts_per_page="1000" order="DESC"]
Don’t forget to click on Publish button on the right of the screen.
Now, this shortcode will support you to display WordPress list posts. However, let’s note that this shortcode is customized to allow the display of up to 1000 posts per page. If you want to change this number, simply edit the number 1000 on the shortcode to whatever number you want.
Now, let’s see what all the posts appear on one page. The visitors can access any post by clicking on the title.
Utilizing Simple Yearly Archive plugin
Firstly, let’s install and activate this plugin by opening Plugins -> Add New, then typing the plugin’s name on the search bar. Finally, you just need to click on Install Now -> Activate.
Now, let’s go to Settings -> Simple Yearly Archive to customize the archive output. There are many options for you to display the posts.
If you hope to showcase them under collapsible years, all you need to do is tick the box next to the Collapsible Years option. In addition, don’t forget to add <div> and <div> at the Before/ After (Year headline) option.
The next step, of course, is pressing the Update options button to save all your settings.
Now, in order to display WordPress list posts on a single page, you simply need to add the shortcode below to the page you want:
Using a custom template and loop
Besides using plugins to display WordPress list posts on one page, you are able to do that by adding code.
First of all, you need to generate a custom page template. After that, from your page.php file, let’s copy the styling. And the last step, all you need to do is utilize the following loop so that all the posts can be displayed on a page:
// the query
$wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?>
<?php if ( $wpb_all_query->have_posts() ) : ?>
<!-- the loop -->
<?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
<!-- end of the loop -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
All in all, with the blog we share today, we hope that it will be useful for you as well as your website. If you have any difficulty or trouble related to this topic, don’t hesitate to share it with us because we may help you solve your problem. What’s more? There are a lot of interesting and Free WordPress Themes here, let’s explore them and get the best one for your site!
- Your php installation appears to be missing the mysql extension which is required by wordpress - January 18, 2023
- 6 Best Toolset Alternatives for Custom Fields And Post Types - December 30, 2022
- How to Remove Noindex Tag In WordPress Post (3 Easy Ways) - December 29, 2022