CMS & WordPress
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?
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.
You could target the post in CSS by its ID.
If you use Firebug you will see the ID of each post, e.g
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)
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
YES! got it working with that second option there starting to really love wordpress development
This topic is now closed. New replies are no longer allowed.