How do I remove Footer in Sticky Posts
-
I actually have 3 requests…
1. How do I remove the footer from sticky posts?
I have seen the following css code, however, once I have this pasted into my stylesheet, I’m not entirely sure how to active it in the post.
div.sticky div.post-footer {display: none;}
2. How can I change the background color of a sticky post?
3. How can I have the sticky post only show on the first/front page?
Thank you.
-Scott
-
1. It really depends on your theme’s markup and CSS. A link to your site would help.
2. Again, depends on your theme’s CSS but something like:
.sticky {background:red;}
at the very bottom of your stylesheet should work.
3. Try using the is_sticky() conditional at the top of the Loop in any template file where you do not want the sticky post to be displayed:
<?php if(have_posts()) : while(have_posts()) : the_post(); ?> <?php if(is_sticky()) continue;?>
1. Link: https://www.9001ventures.com. My assumption is that code should be placed in either the index.php or page.php file, though I’m confused as to what code and where.
2. got it
3. Okay…such as if I did not want it showing up in a archive/search list, I could place this code in archives.php, correct? But what template do I place the code in for pages beyond the frontpage? What I mean is that only X no. of posts will show up on the frontpage of my blog. Then, you must click to go to the next page to see more of the blogs and its those pages I do not want showing the sticky post.
-Scott
My assumption is that code should be placed in either the index.php or page.php file
The main footer is used on every page which is why it’s normally an standalone file that’s included as needed. Makes footer updates way easier. The part I’m confused about is your reference to “footer” with “sticky posts”. Since the latter are normally only “sticky” when displayed in a list/archive of posts, they don’t have a footer of their own. It’s the list that has the footer.
Or are you referring to the category list and comment link that appears at the bottom of each post?
such as if I did not want it showing up in a archive/search list, I could place this code in archives.php, correct?
In archive.php for archives and search.php for search result listings. Although again, not every theme has these templates – in which case, you might find that you’d need to add it to index.php with some extra ‘if’ statement(s).
But what template do I place the code in for pages beyond the frontpage?
That depends upon where/when you want to hide this sticky post. You may want to add it to every post template in your theme. But I have to say that I’ve never used it beyond the front page. and given that the ‘sticky’ concept only has meaning in terms of the front page display, I’m not 100% certain that it will work in other post templates.
Or are you referring to the category list and comment link that appears at the bottom of each post?
Correct. I would like to remove the cat list and comments on only the sticky post (pardon if that’s not included in what I thought was the post footer).
In archive.php for archives and search.php for search result listings. Although again, not every theme has these templates – in which case, you might find that you’d need to add it to index.php with some extra ‘if’ statement(s).
Got it.
That depends upon where/when you want to hide this sticky post. You may want to add it to every post template in your theme. But I have to say that I’ve never used it beyond the front page. and given that the ‘sticky’ concept only has meaning in terms of the front page display, I’m not 100% certain that it will work in other post templates.
Got it.
In addition, is it possible to make the header unlinked…just show the header text, in sticky posts?
-Scott
To remove the postfoot on sticky posts, open index.php and look for:
<div class="PostFooterIcons metadata-icons"> <img height="18" ... Posted in <?php the_category;?> <?php comments_popup_link(...)?> </div>
[Bear in mind that I’ve paraphrased a bit in the above]
Just before that block of code, add:
<?php if(!is_sticky()):?>
and just after, add:
<?php endif;?>
To remove the link on the header for sticky posts, look for:
<span class="PostHeader"> <a title="Permanent Link to <?php the_title(); ?>" rel="bookmark" href="<?php the_permalink() ?>"><?php the_title(); ?></a> </span>
in index.php and replace with:
<span class="PostHeader"> <?php if(!is_sticky()) :?><a title="Permanent Link to <?php the_title(); ?>" rel="bookmark" href="<?php the_permalink() ?>"><?php the_title(); ?></a> <?php else the_title();endif;?> </span>
Thank you. That took care of the postfooter. I did receive the following error message though when applying the header code:
Parse error: parse error, unexpected T_STRING, expecting ‘:’ in /home/content/s/i/e/siegrists/html/9001v/wp/wp-content/themes/9001Ventures_blue/index.php on line 63
I also tried just adding the is_sticky parts to my original script (see below):
`<span class=”PostHeader”>
<?php if(!is_sticky()) :?>” rel=”bookmark” title=”<?php printf(__(‘Permanent Link to %s’, ‘kubrick’), the_title_attribute(‘echo=0’)); ?>”>
<?php the_title(); ?>
<?php else the_title();endif;?>
</span>`Regarding CSS. Though I have added code to my Stylesheet (.sticky), no design changes occur in the sticky post. Do I still need to add some sort of If then statement to my index.php?
I did receive the following error message though when applying the header code
Ack! Sorry – I omitted a colon. Try:
<span class="PostHeader"> <?php if(!is_sticky()) :?><a title="Permanent Link to <?php the_title(); ?>" rel="bookmark" href="<?php the_permalink() ?>"><?php the_title(); ?></a> <?php else : the_title();endif;?> </span>
That did the trick…thank you.
2 last items for the sticky post…
- I understand the CSS addition, though how do I call it into action? Do I place is_stick code somewhere?
- How can I keep the sticky post from appearing in the Recent Posts list?
-Scott
how do I call it into action
On re-checking your index page, it looks like your theme hasn’t been updated to incorporate the
post_class()
function that would automatically add a ‘sticky’ class to the relevant sticky posts. adding this to the index.php template isn’t trivial as there are an awful lot of existing classes that also need to be preserved.How can I keep the sticky post from appearing in the Recent Posts list?
Erm… pass. That’s not one I’ve figured out yet. ??
Bummer on both accounts. Though thank you much for the other code input.
-Scott
<?php if(!is_sticky()) :?><a title="Permanent Link to <?php the_title(); ?>" rel="bookmark" href="<?php the_permalink() ?>"><?php the_title(); ?></a> <?php else : the_title();endif;?>
do you have any idea how to make this work in wp2.8? because it works just fine in 2.7, but that “if is_sticky” doesn’t make any difference in the new version.
actually, it makes a difference: if you use it as “if is_sticky”, then you’ll see it just as it is. if you use it at “if !is_sticky”, it will show all posts (no matter they are sticky or not) as being… sticky.i have this code:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="post"> <?php if (is_sticky()) { ;?> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <?php the_content(__('Read more'));?> <?php } else { ?> <span class="category">Category: <?php the_category(', ') ?></span> <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1> <?php the_content(__('Read more'));?> <div class="postmode"> <?php comments_popup_link('Leave a comment', 'One comment', '% comments'); ?> <?php edit_post_link('- Edit -', '', ''); ?> </div> <?php } ?> </div>
and the sticky post is shown just like the rest of the posts. if I ad a “!” before is_sticky, then I see the rest of the posts (sticky post included) as the first part of the code.
yeah, I guess no one’s around
- The topic ‘How do I remove Footer in Sticky Posts’ is closed to new replies.