ok this is probably simple for someone that understands the loop.
on one page i am showing 5 posts, but when you click "older entries" it doesn't display the next 5 posts. it displays the same posts again... so i am doing something wrong.
disclaimer: i am using category.php to control both the deals and the news section (i don't know if i should have seperate pages for each?) - if someone could explain the pros and cons of having loops for different pages in the category.php then that would be absolutley amazing...
anyway this is the loop i am using at the moment and i think i need something added to it, so that it works properly when you click "older entries"
<?php if (is_category('deals')) { query_posts('category_name=deals&posts_per_page=5'); }; ?>
obviously this is saying, if it's the deals page, show 5 posts, but how do i get it to work properly?
below is the whole code for category.php just incase it helps! =
THANK YOU SO MUCH FOR HELPING ME! I WOULD LOVE YOU IF YOU COULD HELP ME WITH THIS!!!
<?php if (is_category('news')) { ?> <h2>Latest News</h2> <?php } elseif (is_category('deals')) { ?> <h2>Our Deals</h2> <p>Here is a selection of deals that Star Management have been involved in, either representing the club or on behalf of the player:</p> <?php } elseif (is_category('featured')) { ?> <p>My beautiful posts baby!</p> <?php } else { ?>players <p>This is some generic text to describe all other category pages, I could be left blank</p> <?php } ?> <?php if (have_posts()) : ?>
<?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
<?php /* If this is a category archive */ if (is_category()) { ?> <!-- <h2> Star Management Signings <?php single_cat_title(); ?></h2> blocked out cos i have cat dependant headers at the top --> <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?> <h2>Posts Tagged ‘<?php single_tag_title(); ?>’</h2>
<?php /* If this is a daily archive */ } elseif (is_day()) { ?> <h2>Archive for <?php the_time('F jS, Y'); ?></h2>
<?php /* If this is a monthly archive */ } elseif (is_month()) { ?> <h2>Archive for <?php the_time('F, Y'); ?></h2>
<?php /* If this is a yearly archive */ } elseif (is_year()) { ?> <h2 class="pagetitle">Archive for <?php the_time('Y'); ?></h2>
<?php /* If this is an author archive */ } elseif (is_author()) { ?> <h2 class="pagetitle">Author Archive</h2>
<?php /* If this is a paged archive */ } elseif (isset($_GET['paged']) && !empty($_GET['paged'])) { ?> <h2 class="pagetitle">Blog Archives</h2>
<?php } ?>
<!-- this fucking works!! --> <!-- if it's "deals" category then query the posts with a category of "deals" and post 20 per page -->
<?php if (is_category('deals')) { query_posts('category_name=deals&posts_per_page=5'); }; ?> <?php if (is_category('news')) { query_posts('category_name=news&posts_per_page=10'); }; ?> <!-- this fucking works!! --> <!-- i rule -->
I had this problem on my site. Now - I'm very new to all this, so I don't guarantee anything :-) From my understanding, query_posts does not work with pagination (older entries link, etc.) You have to include the paged argument. Here's where I found out about it: http://codex.wordpress.org/Function_Reference/query_posts Try this code for your query:
wow thanks soo much for your help. I used it and it works! i am having issues using it in the news section for some reason, but it works in the deals part!
thanks very much for everything!
i have used it like this... the first loop works a treat, but the second loop doesn't! i don't know why, but maybe someone else could help?!
There is something very important about the loop and using the query_posts function that you are missing. It is the reason why your first attempt at having two loops did not work. After each loop, you must reset the query. It is important to do, even when you are only running query_posts once on a page.
How do you do it? Just add a line like this at the end of the loop after the endwhile at a minimum and if you have navigation at the bottom of the page that takes the user to more pages of stuff in the same loop, then be sure to put this line _after_ that as well.
<?php wp_reset_query(); ?>
Hope this helps. I just figured this out the other day and it has enabled me to do all kinds of fancy things now.
ok this is probably simple for someone that understands the loop.
on one page i am showing 5 posts, but when you click "older entries" it doesn't display the next 5 posts. it displays the same posts again... so i am doing something wrong.
this is the page that i am talking about... http://star-signings.com/category/deals/
disclaimer: i am using category.php to control both the deals and the news section (i don't know if i should have seperate pages for each?) - if someone could explain the pros and cons of having loops for different pages in the category.php then that would be absolutley amazing...
anyway this is the loop i am using at the moment and i think i need something added to it, so that it works properly when you click "older entries"
obviously this is saying, if it's the deals page, show 5 posts, but how do i get it to work properly?
below is the whole code for category.php just incase it helps! =
THANK YOU SO MUCH FOR HELPING ME! I WOULD LOVE YOU IF YOU COULD HELP ME WITH THIS!!!
From my understanding, query_posts does not work with pagination (older entries link, etc.) You have to include the paged argument. Here's where I found out about it:
http://codex.wordpress.org/Function_Reference/query_posts
Try this code for your query:
I think this might work :-)
wow thanks soo much for your help. I used it and it works! i am having issues using it in the news section for some reason, but it works in the deals part!
thanks very much for everything!
i have used it like this... the first loop works a treat, but the second loop doesn't! i don't know why, but maybe someone else could help?!
It's the same as @hayley's code, just with less "stuff".
There is something very important about the loop and using the query_posts function that you are missing. It is the reason why your first attempt at having two loops did not work. After each loop, you must reset the query. It is important to do, even when you are only running query_posts once on a page.
How do you do it? Just add a line like this at the end of the loop after the endwhile at a minimum and if you have navigation at the bottom of the page that takes the user to more pages of stuff in the same loop, then be sure to put this line _after_ that as well.
Hope this helps. I just figured this out the other day and it has enabled me to do all kinds of fancy things now.
Cheers!
I learned this much from this post.
I have created posts for different lightboxs.
For lightbox post i have catagory called 'lightbox' When i click on link.
[lightbox href="http://localhost/?p=229" iframe="true" width="700" height="460"]Open [/lightbox]
It opens whole post with header and sidebar and everything.
I was wondering if we can hide header, sidebar, footer everything except that post data. That would be great...
Please let me know if its possible and how can i achive this.
Thanks a ton.
* I am using twenty eleven theme.