What code, and where would I place it, to make only sticky post titles presented as <h1>?
What code, and where would I place it, to make only sticky post titles presented as <h1>?
Hi,
You can use the custom stylesheet for your sticky post. Refer this article for more details
http://codex.wordpress.org/Theme_Development#Theme_Style_Sheet
Thanks,
Shane G.
Something like:
<?php if( is_sticky() ) ?><h1>
<?php else ?><h2>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php if( is_sticky() ) ?></h1>
<?php else ?></h2>
should work in index.php
Thanks Shane G
The code you provided esmi does not function in this case. I am using a theme that does not presently recognize sticky posts. I had to add the following code in order to make sticky posts effective. Is there a way to edit this code to accomplish my inquiry?
<?php query_posts(array('post__in'=>get_option('sticky_posts'))); ?>
-Scott
I am using a theme that does not presently recognize sticky posts
The conditional should still work - even if your current theme doesn't normally highlight sticky posts in any way. It's a WP database flag rather than a theme one.
Unfortunately, I placed the code in index.php and I received a php error. Should it be placed in a specific position w/in index.php?
"Parse error: syntax error, unexpected T_ELSE in..."
Ah! Now that's different. That's just sloppy coding/typing on my part. :-)
Try:
<?php if( is_sticky() ) :?><h1>
<?php else :?><h2>
<?php endif;?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php if( is_sticky() ) :?></h1>
<?php else :?></h2>
<?php endif;?>Okay, no errors, but now it just displays 2 titles, both as <h2> :-)
Here's my post title code in common.php that is setting post titles as <h2>:
<h2 class="h2-simulate-h1-size"><a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); // Because single post or pages are more important for indexing, multiple post pages just have a h2 title for each item
?>
</a></h2>
Here's the code to only display sticky posts on home page in my home/index.php:
<?php query_posts(array('post__in'=>get_option('sticky_posts'))); ?>
Wondering if maybe there's a means to combine your code with my existing post tile code above.
-Scott
Since this is not working out to well, I'm going to change approaches and have started a new post:
http://wordpress.org/support/topic/328607?replies=1#post-1271093
This topic has been closed to new replies.