jonfoster
Member
Posted 1 year ago #
Hi everyone,
I'm quite new to the whole WordPress thing, and haven't had much experience with CSS either, so sorry if this is a bit obvious - or not written properly!
Basically I'd like to know how I can make the title of Sticky posts show up differently to the title of normal posts - specifically be <h1> rather than <h2>.
Thanks in advance,
Jon
You should look at using the 'is_sticky()' conditional in your theme.
Rough example (not tested)
if(is_sticky) {
echo '<h1>'.get_the_title().'</h1>';
} else {
echo '<h2>'.get_the_title().'</h2>'
}
jonfoster
Member
Posted 1 year ago #
Thats great - I'll give it a go.
Thank you!
get_the_title() is not santized, use the_title() instead.
<?php if( is_sticky() ) : ?>
<h1><?php the_title(); ?></h1>
<?php else : ?>
<h2><?php the_title(); ?></h2>
<?php endif; ?>
jonfoster
Member
Posted 1 year ago #
Mark - that's worked perfectly - thank you SO much.
Jon