meganlee1984
Member
Posted 9 months ago #
I'm showing several query posts in the sidebar. It seems to work fine until I wanted to show more than one post in the query. I thought I could just update: Post_Per=Page=2
But that doesn't work. I don't want to run another loop because it creates a dividing line between the section, but is this my only option?
The loops:
[code moderated per forum rules - please follow http://codex.wordpress.org/Forum_Welcome#Posting_Code for posting code]
meganlee1984
Member
Posted 9 months ago #
Instead of <? wp_reset_postdata(); ?> try <? wp_reset_query(); ?>.
And, I'm a little bit mystified (looking at code out of context is always difficult) as to why you have two queries for each set of posts?
What is $custom_query used for, as I can't spot it anywhere else in your code? This may be why it's not working for the second loop -
Should this -
$second_query = new WP_Query('cat=-5, -8');
$custom_query = new WP_Query('posts_per_page=1');
Just be this -
$second_query = new WP_Query('cat=-5,-8&posts_per_page=1'); // Change posts_per_page and cat as needed
meganlee1984
Member
Posted 9 months ago #
Thanks for the response, I have two queries, because I am showing two separate areas of two category specific posts.
This is the page:
http://svadsi.info/
Basically I want to show the latest post from the "Events" category, and the two latest post from the "News" Category. Does that make sense? Or Do you think I'm using this in the wrong context still? If so please let me know.
Thanks!
meganlee1984
Member
Posted 9 months ago #
Just be this -
$second_query = new WP_Query('cat=-5,-8&posts_per_page=1'); // Change posts_per_page and cat as needed
This did it! Thanks!
It's really difficlut to say without knowing your exact set up, but I'm inclinded to say that your could reduce the number of queries (speed things up) and still achieve the same result.
Let me see if I understand what you are doing - You wish to show one post from a defined set of categories under the heading 'Events', and then two posts from a set of defined categories under the heading 'News'?
If so, you can reduce it to one query per section, as it were, so two in total as opposed to the four you have.
Ha ha, both writing at the same time! Glad you have it sorted. Could you please mark this thread as 'Resolved' using the form on the right.