Posts

Showing posts from April, 2017

HOW TO LIMIT NUMBER OF DISPLAYED POSTS IN WORDPRESS

Image
It's totally easy and is almost clearly written in the Wordpress documentation. I will go straight to the point. You will have to know a little bit of PHP. In your themes folder, open the index.php file. In the file you will find this code(without the curly braces): { if ( have_posts() ) }  this code queries your database for posts with the default setting from your Wordpress Dashboard. Just before the code(without the curly braces), input this code to modify the query: { $query = new WP_Query( array( 'posts_per_page' => 4 ) ); } "You can change the number of posts that suits your design." Then you need to modify further. Change the following....   { if ( have_posts() ) } to { if ( $query-> have_posts() ) } {while ( have_posts() )} to { while ( $query->have_posts() )} {the_post()} to {$query->the_post()}  So that's all you need to do Happy coding :)