In addition to displaying sticky post(s) first, that’s the goal here?
Here’s my guess:
1. Get 5 posts in the category=featured, and the sticky posts.
2. On the first of those posts display the_content and on the rest display the_excerpt.
Question:
When displaying the sticky posts, what displays–the_content or the_excerpt?
Thread Starter
l r
(@lainyrache)
Hi Sorry – I was not very clear.
Thanks for getting back to me.
1. Yes I want 5 posts from category=featured, some will be stickies, the stickies should be at the top.
2. All posts display either
full content or shortened content via the more tag
or if excerpt exists show a bespoke excerpt.
I am hard coding the ‘read more of this entry >>’
It’s not ideal but I couldn’t get it to link to the full content consistently.
When the sticky displays – I have the excerpt or the content whichever exists.
Well you can play with this:
<?php
$cat=get_cat_ID('featured');
$posts=get_posts(array('post__in'=>get_option('sticky_posts'))); // get sticky posts
if ($posts) {
foreach($posts as $post) {
setup_postdata($post);
if ( in_category($cat) ) { // only sticky posts in selected category
?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
the_content('Read the rest of this entry »');
}
}
}
$posts=get_posts(array('post__not_in'=>get_option('sticky_posts'),'cat'=>$cat,'showposts'=>5)); //get posts in our category, exclude sticky posts
if ($posts) {
foreach($posts as $post) {
setup_postdata($post);
?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
the_content('Read the rest of this entry »');
}
}
?>
Needed two loops, one to process the sticky posts in your category, then another to process the non-sticky posts.
Thread Starter
l r
(@lainyrache)
Hi Michael…
quick test ..it kind of does it – need to mess around… will get there..
Thank you..