How to Display All Posts on One Page In Your WordPress | Different File

Please log in or register to like posts.
News

How to Display All Posts on One Page In Your WordPress Different File

Hi WordPress Beginner’s. Today I’m Going To Show You How To Show Your All Posts On One Different Page Such As allposts.php File. You Can Display All Your WordPress Posts on One Page. Recently One Of Our Reader Wanted To Create An Archives Page And Show All WordPress Posts On a Single Page. In This Article, We Will Show You How To Display All Your WordPress Posts On One Page Without Pagination. First You Can Read More WordPress Tutorials From Below.

10+ Most Wanted Tips, Tricks, and Hacks
How To Highlight Author Comment Using Only CSS
How to Fix 404 Post Returning Error Issue
How to fix Establish Database Connection
50+ WP Tips

[ads]

Posts

First Go To Your Hosting And Go To The WordPress Theme Folder e.g wp-content/themes/themename/ Then Make A Folder Called Custom And Then Enter To The Custom Folder. Make New File Called allposts.php And Then Copy Past The Below Code.

<?php 
// the query
$howtrick_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?>

<?php if ( $howtrick_all_query->have_posts() ) : ?>

<ul>

	<!-- 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 -->

</ul>

	<?php wp_reset_postdata(); ?>

<?php else : ?>
	<p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>

Now Save This File. Then Go To Your Theme File Where You Want TO Show Your All Posts Such As index.php And Past this Below Code To A Place Where You Want To Show Your All Posts.

<?php get_template_part( 'Custom/allposts' ); ?>

Then Save The File. Now Go To Your Website HomePage, Magic!! It’s Working. If You Have Problems And Need To Know Something About This Snippet Just Drop Your Comment.

More WordPress Custom Functions

10+ Most Wanted WordPress Tips, Tricks, and Hacks – HowTrick
How to Fix WordPress 404 Post Returning Error Issue
How to fix Establish Database Connection in WordPress
What is Internal server error and how to fix – WordPress
How To Display Random Posts in WordPress – Coding
How to Change the WordPress Login Logo – Custom Logo
WordPress Theme Development « WordPress Codex
8 Extremely Useful WordPress Functions For Developers

[ads]

Nobody liked ?

Leave a Reply

Your email address will not be published. Required fields are marked *