How do I show 4 full entries and 10 older entries by title?
-
Hi all,
I am using the following code on my main index, see my pastebin: http://pastebin.com/622024
The code shows one main/full post with remainder showing just as titles.
Now how do I ammend the code to show 5 main/full posts and then the 5 posts after those as titles?
does that make sense?
Thanks
-
is there noone who can give me guidance?
Thank you
Should I go by what you’re asking for in the subject line of this post, or the content?
Subj: 4 full/10 next as titles
Cont: 5 full/5 next as titlesWhatever the numeric values are supposed to be, for your
N
first posts with full content, alter the ‘showposts’ value in your new WP_Query class parameter to the amount of posts you want to display. Then I suggest scrapping the bottom loop and making use of get_posts(), so you can provide an offset from the firstN
posts above it. Mod and removal of most of the extraneous code found here (assumes 5/5):Also, I provide a much different solution working with the pre-existing or default loop (and just the one) here:
Another way would be to use something like this inside the loop:
<?php
if (have_posts()) {
// full post for the first 5 posts
$i = 1;
while($i < 6) {
the_post();
echo $post->post_title . '<br/>' . the_content();
$i++;
}// just titles for the next 5
$i = 1;
while($i < 6) {
the_post();
echo $post->post_title . '<br>';
$i++;
}
}
?>Thanks Guys, I will check this out in the morning (I’m in da UK)
Thank you for your help.
Hi Kafkaesqui
I am using the post code you very kindly supplied me and it appears to work just fine, but (theres always a but), I have a hidden category called ‘events’ that does not show up on the ‘home’ page. It seems these hidden posts are screwing up the listings and the calculation repeats titles that are already listed in the first 5 main posts.
Is there a way (somehow) to ignore these when it comes to the calculation?
Many thanks
“Is there a way (somehow) to ignore these when it comes to the calculation?“
In your first post loop, yes. An argument of ‘
cat=-10
‘ can be passed to WP_Query() and that *negates* or filters out the category ID of10
. But there’s no way to do that with get_posts().I think your best option here is to just use a standard single Loop and change what you display based on a count off of the posts. The alternative I provide above or marke1’s suggestion would do that.
Kafkaesqui,
Thank you for the reply.
This is where I show my lack of knowledge here. How would I actually show the argument in, say, your code: http://pastebin.com/622347
Thinking about it, how would I use your alternative with my ‘content’ setup as seen here: http://pastebin.com/623557
thanks again
FiShowing ones lack of knowledge around here is not a problem. We all start somewhere. Refusing to admit ones lack of knowledge, on the other hand… Anyway, we’ll make this really easy. And I’m moving the thread to a somewhat longer lived pastebin site:
Note the following two “user-configurable” variables at the top of the code block:
$showposts (set to 10)
$firstposts (set to 5)I also commented throughout the source, but ask if anything isn’t clear.
EDIT: Revised the pastebin code as I needed to comment out a few functions for plugins I don’t run. They are comment-free in new pastebin entry.
Kafkaesqui, That is incredibly kind of you. Thank you.
Is the option to filter out a category in your code?
Again, thankyou.
Do you have a donation link?
Fi
Fiona,
To filter a category just add to the arguments in the query_posts() call:
query_posts("showposts=$showposts");
to:
query_posts("showposts=$showposts&cat=-1");
Change the
-1
for the cat value to-N
,N
being the category ID for the category you want filtered out.I have a donation button on my site, but let’s not talk about that…
Thankyou again Kafkaesqui,
There seems to be a very slight problem, the last full post does not show as a full post but a title. See my code here: http://pastebin.co.uk/580
See how there is a list < li > item just above ‘Older Entries’?
What could be causing this?
Kind regards
FiKafkaesqui, Thankyou x 1 million 🙂
I really do appreciate your help with all this. It works just fine now.
Regards
Fi
- The topic ‘How do I show 4 full entries and 10 older entries by title?’ is closed to new replies.