ThemeShaper Forums » Thematic

[closed]

Changing post-meta order

(4 posts)
  • Started 8 years ago by Andrew
  • Latest reply from Andrew
  • This topic is resolved
  1. Hi Guys, I feel really stupid. I got this to work in an earlier version but ended up overwriting my functions.php and now I'm tryin to figure it out again, but I can't for the life of me. Its a question of my limited PHP knowledge, and WP functions.. I want to change the normal output of thematic's postheader_postmeta as seen below..

    function thematic_postheader_postmeta() {
    
        $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_authorlink();
        $postmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
        $postmeta .= thematic_postmeta_entrydate();
    
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
    
        return apply_filters('thematic_postheader_postmeta',$postmeta); 
    
    } // end thematic_postheader_postmeta

    to a new order like this one here

    $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate();
        $postmeta .= thematic_postmeta_authorlink();
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";

    Im familiar with the add)action and remove_action functions but I don't know how to work with filters much yet.. What can I call in my child themes functions.php to have the lower code, replace the code in the upper portion (thematic_postheader_postmeta).

    Thanks a bunch for any help!

    Posted 8 years ago #
  2. function child_postfooter () {
    $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate();
        $postmeta .= thematic_postmeta_authorlink();
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
    }
    add_filter('thematic_postfooter','child_postfooter');

    should work to filter in your function. if you don't add some space in between the date, author and edit links... i suspect they will jumble right up on top of each other.

    Posted 8 years ago #
  3. Hi Helga, Thanks for the response.. A few questions though. Why would you hook the new filter onto 'thematic_postfooter' if I want to change teh order of the 'thematic_postheader_postmeta' as in the first bit of code to my new order.

    I've tried you're code above and it doesn't work going straight into my functions.php.. trying to tweak it a bit I've come up with

    function sybarity_postheader () {
        $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate();
    
        $postmeta .= thematic_postmeta_authorlink();
    
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
    }
    add_filter('thematic_postheader_postmeta','sybarity_postheader');

    But still no luck, actually this removes my post headers completely.. Sorry for my dense-ness..
    Any idea's?

    Posted 8 years ago #
  4. Allright! I figured it out. I really had a hard time getting anything to change the contents/order of the postmeta within thematic_postheader_postmeta, so instead I removed it and added my own and applied a filter to the thematic_postheader to call my new postmeta function instead..

    // Functions to change order of Post Meta
    // Removing Thematic's Postmeta
    
    function remove_oldpostmeta() {
    remove_action('thematic_postheader', 'thematic_postheader_postmeta');
    }
    add_action('init', 'remove_oldpostmeta');
    
    //  Creating my new postmeta order
    function sybarity_postheader_postmeta () {
    $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate();
    
        $postmeta .= thematic_postmeta_authorlink();
    
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
    
    return apply_filters('sybarity_postheader_postmeta',$postmeta); 
    
    }
    //  Applying the new postmeta order to Thematic's postheader with a filter
    function sybarity_postheader() {
    
        global $post;
    
        if ($post->post_type == 'page' || is_404()) {
            $postheader = thematic_postheader_posttitle();
        } else {
            $postheader = thematic_postheader_posttitle() . sybarity_postheader_postmeta();
        }
    
    	return $postheader;
    
    }
    
    add_filter('thematic_postheader', 'sybarity_postheader' );

    Thanks for your help Helga, and Chris too in this post.

    Posted 8 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.