In my Wordpress admin panel, in the section 'Settings' -> 'Reading', I have set the 'Blog pages show at most' value as 5 and I have the 'Your homepage displays' value set to 'Your latest posts'. I am trying to bypass this on my front-page.php loop by setting the 'posts_per_page' argument of the query to 2 (or any number other than 5) and I haven't added a 'pre_get_posts' hook in my functions.php file. But the result always shows 5 posts.
This is my front-page.php file:
<?php get_header(); ?>
<?php
global $wp_query;
$wp_query->set('posts_per_page', 2);
if ($wp_query->have_posts()) {
while ($wp_query->have_posts()) {
//var_dump($wp_query->get('post_type'));
$wp_query->the_post();
the_title();
echo '<br>';
}
echo paginate_links();
}
?>
<?php get_footer(); ?>
Kindly let me know how I can bypass the value that I have set in the admin panel.
Thank You, Clement