• Resolved jonfoster

    (@jonfoster)


    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • 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>'
    }
    Thread Starter jonfoster

    (@jonfoster)

    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; ?>
    Thread Starter jonfoster

    (@jonfoster)

    Mark – that’s worked perfectly – thank you SO much.

    Jon

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Change the title of a Sticky post’ is closed to new replies.