ThemeShaper Forums » Thematic

[closed]

how can override thematic_postfooter()

(9 posts)
  • Started 3 years ago by kinghokum
  • Latest reply from Danieliser
  • This topic is resolved
  1. kinghokum
    Member

    Hi guys,
    i'm looking for a way to override the function thematic_postfooter.
    My plan is to remove the categories and post tags info from the div .entry-utility located in the post footer.

    I know you can remove the div tages for these 2 things using css, but I'm trying to get to grips with usings functions to remove some content.

    heres the existing thematic_postfooter function:

    // Information in Post Footer
    function thematic_postfooter() {
        global $id, $post;
    
        if ($post->post_type == 'page' && current_user_can('edit_posts')) { /* For logged-in "page" search results */
            $postfooter = '<div class="entry-utility">' . thematic_postfooter_posteditlink();
            $postfooter .= "</div><!-- .entry-utility -->\n";
        } elseif ($post->post_type == 'page') { /* For logged-out "page" search results */
            $postfooter = '';
        } else {
            if (is_single()) {
                $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . thematic_postfooter_posttags() . thematic_postfooter_postconnect();
            } else {
                $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcategory() . thematic_postfooter_posttags() . thematic_postfooter_postcomments();
            }
            $postfooter .= "</div><!-- .entry-utility -->\n";
        }
    
        // Put it on the screen
        echo apply_filters( 'thematic_postfooter', $postfooter ); // Filter to override default post footer
    } // end thematic_postfooter

    so if I want to create my own function like, the following, how can I get it to override the thematic 'thematic_postfooter' function ?

    Any help is appreciated.

    function my_postfooter() {
        global $id, $post;
    
        if ($post->post_type == 'page' && current_user_can('edit_posts')) { /* For logged-in "page" search results */
            $postfooter = '<div class="entry-utility">' . thematic_postfooter_posteditlink();
            $postfooter .= "</div><!-- .entry-utility -->\n";
        } elseif ($post->post_type == 'page') { /* For logged-out "page" search results */
            $postfooter = '';
        } else {
            if (is_single()) {
                $postfooter = '<div class="entry-utility">' . thematic_postfooter_postconnect();
            } else {
                $postfooter = '<div class="entry-utility">' . thematic_postfooter_postcomments();
            }
            $postfooter .= "</div><!-- .entry-utility -->\n";
        }
        echo apply_filters( 'my_postfooter', $postfooter );
    }
    Posted 3 years ago #
  2. Goran
    Member

    Something like this

    function my_postfooter($postfooter) {
    //this won't do anything except display the same footer
    echo $postfooter;
    }
    add_filter('thematic_postfooter', 'my_postfooter');

    I haven't been working long with Thematic, but I figure the only way to remove the container without copying the whole function and modifying it, is to manipulate the string you receive. Something like:


    echo str_replace(array('<div class="entry-utility">', '</div>'), array('',''), $postfooter);

    Posted 3 years ago #
  3. kinghokum
    Member

    Thanks Goran, you got me on the right track.

    Posted 3 years ago #
  4. iCristiano
    Member

    I have an issue about it... I´m trying to override my postfooter using this code:

    function my_postfooter_postutility() {
    
        $postutility = '<div class="entry-utility">'. the_tags('Assuntos: ') . '</div>';
    
        return $postutility;
    }
    add_filter('thematic_postfooter','my_postfooter_postutility');

    It works, but the tags comes out of the <div></div>...
    the html result of this is:

    Assuntos:
    <a rel="tag" href="http://www.mylink1.com">tag1</a>
    ,
    <a rel="tag" href="http://www.mylink2.com">tag2</a>
    <div class="entry-utility"></div>

    Whats wrong??
    Thanks!

    Posted 3 years ago #
  5. Danieliser
    Member

    its because the the_tags() funciton has to be called inside the loop. The footer is below the loop so i doesnt get an ID to get tags for. Not sure but i think you can pass $post->ID to the function and then use wp_get_post_tags( $post_id )
    Something like this.

    function my_postfooter_postutility() {
        $global $post;
        $tags = wp_get_post_tags( $post->ID );
        foreach($tags as $tag){
            $tag-list .= '<a href="'. get_bloginfo('wpurl') . '/tags/' . $tag->slug . '/" title="'. $tag->name . '">'. $tag->name . '</a> ';
        }
        $postutility = '<div class="entry-utility">'. $tag-list . '</div>';
    
        return $postutility;
    }
    add_filter('thematic_postfooter','my_postfooter_postutility');
    Posted 3 years ago #
  6. iCristiano
    Member

    I don´t know if its the problem, because it gets the right tags... but not inside the <div></div>

    I tryed your suggestion, it works, but print the word "array" before the tags and don´t print any sepparation between the tags. This is the result:

    Arraytag1 tag2

    Any idea?

    Posted 3 years ago #
  7. Danieliser
    Member

    Well the_tags() from the wordpress codex specifically states that it must be used inside the loop. and by my experience(i could be wrong) ive never gotten things like that to work.

    my mistake on that.. there were a few mistakes.. '$golbal $post' should be 'golbal $post' and '$tag-list' variable needs to be '$tag_list'. Here is a revised function with a ', ' seperator.

    function my_postfooter_postutility() {
        global $post;
        $tags = wp_get_post_tags( $post->ID );
        $tag_list = '';
        $count = count($tags);
        $i=0;
        foreach($tags as $tag){
            $i++;
            $tag_list .= '<a href="'. get_bloginfo('wpurl') . '/tags/' . $tag->slug . '/" title="' . $tag->name . '">' . $tag->name . '</a>';
            if($i < $count) $tag_list .= ', ';
        }
        $postutility = '<div class="entry-utility">'. $tag_list . '</div>';
    
        return $postutility;
    }
    add_filter('thematic_postfooter','my_postfooter_postutility');

    Tested working!!

    Posted 3 years ago #
  8. iCristiano
    Member

    Perfecto! Gracias! ;)

    Posted 3 years ago #
  9. Danieliser
    Member

    not a problem..

    You can find some other useful functions at
    http://thematic.wizardinternetsolutions.com/

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.