ThemeShaper Forums » Thematic


how to remove meta data, comments etc from a sticky post?

(9 posts)
  • Started 11 years ago by onelittlemoose
  • Latest reply from helgatheviking
  • This topic is resolved
  1. onelittlemoose

    Following my post here
    I've determined that what I need is a sticky post, but need to remove the meta data and whatnot so it appears only as a welcome message, not a post.

    I would know how to do this in css, but know enough to know that's not the best way.
    Wordpress forums suggest adding the below to loop.php, but how would I re-write to add this to functions.php ?

    <?php if( !is_sticky() || !is_home() ) :?>
    <div class="entry-utility">
    </div><!-- .entry-utility -->
    <?php endif;?>


    Any help is welcome, thanks.

    Posted 11 years ago #
  2. looks like you understand conditional logic, so now you just need to merge that with an understanding of filters, b/c you can easily adjust the entry-utility and entry-meta by targeting the appropriate filter in thematic. here's my short run-down on how to filter which should get you started

    Posted 11 years ago #
  3. onelittlemoose

    Thanks for your help, helgatheviking. I really like your parking analogy, and after resisting the urge to run away screaming from the code, I've spent some time on your tutorial and managed to hobble together something. Unfortunately my results are not very good...

    First, the code I tried, starting with baby steps and trying to remove the postmeta:

    function childtheme_override_postheader_postmeta($postmeta) {
    		if (is_sticky()) {
    		$c[] = 's-sticky';
    		$postmeta = ''; }
    	return apply_filters('thematic_postheader_postmeta',$postmeta);

    This gives error:
    Fatal error: Cannot redeclare childtheme_override_postheader_postmeta() (previously declared in /functions.php:54) in /functions.php on line 103

    Oopsie, I had previously asked it to remove the author bits on regular posts. So at first glance, initially, that's the cause of the error. But, are my logic and syntax even on the right track? Should my "if" part come before the function part, or should my "if" be added to the previous filter that removed the author part? (

    I have difficulty in deciphering, whether they be function/action/hook/filter, what is an_example_name which I could replace with my_custom_name, versus what is the_official_name and therefore I must use the_official_name.

    I fear I am completely revealing my ignorance here, and I thank you hugely for any and all help.

    Posted 11 years ago #
  4. onelittlemoose

    Ok, I think I might be on to something here. I added my if statement to the previous childtheme_override_postheader_postmeta which was intended to remove the author from the postmeta

    // removes author information from postmeta
    function childtheme_override_postheader_postmeta() {
    	$postmeta = '<div class="entry-meta">';
    	$postmeta .= thematic_postmeta_entrydate();
    	$postmeta .= thematic_postmeta_editlink();
    	$postmeta .= "</div><!-- .entry-meta -->\n";
    //this bit removes everything from the sticky post only
    	if (is_sticky()) {
    		$postmeta = '<!-- sticky post has no entry-meta -->'; }
    // and this part was there before, to apply it all
    	return apply_filters('thematic_postheader_postmeta',$postmeta);

    It seems to work, no errors.... and my regular posts still look like how I want.

    I'm beginning to get it, sort of. I'm not entirely sure though, why I would apply_filters versus add_filter.

    Next up to find the magic ingredients that remove the link from the post title of the sticky post, and then the sticky post footer bits.

    Posted 11 years ago #
  5. onelittlemoose

    Ok, some slight progress, sort of. I figured out how to get rid of the postfooter (the comments, tags, edit link). Unfortunately, my if statement doesn't seem to be working, as it's removed the postfooter on every single post. This is my code:

    // here were are in the post footer
    function childtheme_override_postfooter() {
    //this bit is supposed to remove the post footer from the sticky post only
    	if (is_sticky()) {
    		$postfooter = '<!-- sticky post has no postfooter -->';
    // and this part applies it
    	return apply_filters('thematic_postfooter',$postfooter); }

    It seems to be overriding all postfooter instructions, regardless of sticky or not. I thought at first that it meant I need to re-instruct it as to what to do with the non-sticky, and pasted in the original thematic_postfooter instructions, but that gave me a "can't re-declare function thematic_postfooter" type of error message.


    On a sidenote, I think I figured out why it's apply_filters as opposed to add_filter. But I don't think I could explain to others just yet...

    Posted 11 years ago #
  6. "//this bit is supposed to remove the post footer from the sticky post only"

    your logic is right, but if you don't have the ELSE part of that statement the override function isn't the best choice b/c the ELSE is defined as nothing so you won't see it on any pages at all. therefore, i think you'd be better served by a filter

    //remove the post footer from the sticky post only
    function kia_postfooter($postfooter) { //send thematic's variable into the function
    	if (is_sticky()) { //if true, change the variable somehow
    		$postfooter = '<!-- sticky post has no postfooter -->';
        return $postfooter; //either way, send the variable back to thematic's apply_filters hook

    "can't re-declare function thematic_postfooter" means you have 2 functions named the same which is obviously a no-go.

    Posted 11 years ago #
  7. onelittlemoose

    Yours makes much more sense than what I've since arrived at. By doing a child theme function override, I see now that it means once you've changed the bit you wanted, you still have to re-instruct it on what to do with everything else (the ELSE part you allude to).

    I had that working thanks to a copy/paste from the content-extensions.php (minus the thematic_postfooter declaration and with minor editing), but it all seemed rather clunky. I figured there must be a better way. However that was not a waste of time because I learned things along the way.

    So your name, "kia_postfooter" is this an arbitrary name, or is an essential defined name? In other words, could it just as easily been named "myspecialfilter_postfooter" ?

    I think I may have figured out how to do remove the link from from the post title as well, but in light of the above, I will take another look because it also seemed a bit clunky.

    Many thanks. I hope to BRB.

    Posted 11 years ago #
  8. onelittlemoose

    Wow, this totally works

    //remove the link in the post title from the sticky post only
    function forstickypost_posttitle($posttitle) { //send thematic's variable into the function
    	if (is_sticky()) { //if true, change the variable somehow
    		 $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
        return $posttitle; //either way, send the variable back to thematic's apply_filters hook

    And I now know more of the difference between apply_filters and add_filter. In fact I have learned so much, in addition to the confidence gained.

    Yay! Happy dance!

    Thank you, a thousand times!

    Posted 11 years ago #
  9. now you know... and knowing is half the battle. ;) glad you are getting your head wrapped around it. now that you've got filters you can do anything!!! well... almost

    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.