zany90 — 2012-10-02T04:20:14-04:00 — #1
Ok, Ive developed a theme where basically the posts display the title, the date and category (which is highlighted), the post contents and a read more link... However i have now decided to add an introductory "sticky" post, just an "about me" post which will stay at the top... I know how to make the posts sticky ok, what im wondering though is how i customize this posts appearance compared to all the standard non-sticky posts?
I looked at the html and the sticky post doesn't seem to have a class or anything that defines it as a sticky post, so can't just add the class name to the css and give it different rules.. I would like this post to only display the title, no date or category or read more link (as the entire post will be displayed), and possibly add a different background colour to this one..
Anyone able to help?
cheesedude — 2012-10-02T04:44:34-04:00 — #2
You can test to see if the post is sticky then load a custom template.
If you don't get a more definitive answer within 24 hours, I'll see what I can do.
qwaerstd — 2012-10-02T10:42:51-04:00 — #3
You could target the post in CSS by its ID.
If you use Firebug you will see the ID of each post, e.g
zany90 — 2012-10-02T18:11:14-04:00 — #4
Thanks, although im going to need to use the php option as well i think if i only want "content" with this post and not title and no date/category/read more etc...
am i right in thinking the loop should look like this for what i want?
<?php if (have_posts ()) : ?>
<?php while(have_posts()) : the_post(); ?>
<article id="sticky_post"><?php the_content(); ?></article>
<h2 class="post_title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
<p class="date"><?php the_time('F jS, Y') ?><br />
Posted in: <?php the_category(', ') ?></p>
<div class="grey"><?php the_content(''); ?></div>
<a href="<?php the_permalink() ?>" class="readmore">Read More...</a>
<?php endwhile; ?>
<li id="older"><?php next_posts_link('Older Posts') ?></li>
<li id="newer"><?php previous_posts_link('Newer Posts') ?></li>
<?php else : ?>
<?php endif; ?>
I know that definitely doesnt seem right... jsut want to get some knowledge before i go messing with my theme again... the bold section is the bit with the is_sticky query.. what i want is for any "sticky" posts to only display content and with an id which i can target in my css, where the rest of the posts display as shown/formatted (with title, date, category and the read more link)
zany90 — 2012-10-02T18:14:17-04:00 — #5
maybe instead of <?php endif; ?> underneath the sticky post query it should be <?php elseif(!is_sticky()): ?> (ALL THE FORMATTING FOR NON STICKY POSTS) followed by <?php endif; ?>
anyone? help greatly appreciated
zany90 — 2012-10-02T19:10:43-04:00 — #6
YES! got it working with that second option there starting to really love wordpress development