Ok so i normally display 8 post per pages, but with the selection of a parameter, i want the user to see only a single post per page differently. That is not a problem on how i will show it differently as its already done, but my issue is when i try to change the loop.
I’ve looked for hours online and i beleive i just don’t know enough of WordPress, but i can tell that
query_posts('showposts=1');
doesnt fix the issue.
Basically i need to only show a single post, so i would like to know if there is a simple way to change the value of this famous “Blog pages show at most” in the settings sections. I just want to change that value before i go into my loop. Thats it thats all, if somone has an awnser to this, i would be really happy to finally fix this problem.
Thanks.
This code snippet is changing the actual value of the Blog pages show at most.
It did work and you can see it when you go into the admin tool. Although be carefull its permanant, so use this with high attention.
I think you should be using the following snippet:
query_posts( 'posts_per_page=1' );
this is depicted in query_posts wordpress codex page
You could take a look at the
pre_get_posts
hook. It is generally preferred over thequery_posts()
function because it doesn’t cause a second query to run.Also, if you want to learn more about WP_Query and how WordPress uses it, I highly recommend this video: You Don’t Know Query