ThemeShaper Forums » Thematic

[closed]

help with postheader_postmeta filter

(6 posts)
  • Started 3 years ago by JC
  • Latest reply from JC
  • This topic is resolved
  1. JC
    Member

    Hello everybody !

    I need to change display order for postheader_postmeta information (I need to have the date first) but ONLY for single post view (not home/blog etc..) so I tried with this following code without success.

    // Put date first in postheader
    function childtheme_postheader_postmeta() {
    if (is_single()) { // only for single post
        $mypostmeta = '<div class="entry-meta">';
        $mypostmeta .= thematic_postmeta_entrydate();
        $mypostmeta .= thematic_postmeta_authorlink();
        $mypostmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
    
        $mypostmeta .= thematic_postmeta_editlink();
    
        $mypostmeta .= "</div><!-- .entry-meta -->\n";
    
        return $mypostmeta;
        }
    } // end childtheme_postheader_postmeta
    add_filter('thematic_postheader_postmeta', 'childtheme_postheader_postmeta');

    The problem is that the above code works ok when it's a single post, but when it's not the postheader_postmeta info desappears (nothing is displayed) instead of being displayed with the default order.

    Could someone be kind to help me ?
    thank you !

    Posted 3 years ago #
  2. 2 problems that i think i see. first you are only 'returning' the $mypostmeta variable in the is_single() if statement, so nothing will get returned on any other page. Also you are not returning $postmeta at all, which is why it is blank on the other pages. try this:

    // Put date first in postheader
    function childtheme_postheader_postmeta() {
    if (is_single()) { // only for single post
        $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate();
        $postmeta .= thematic_postmeta_authorlink();
        $postmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
    
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
        }
        return $postmeta;
    
    } // end childtheme_postheader_postmeta
    add_filter('thematic_postheader_postmeta', 'childtheme_postheader_postmeta');
    Posted 3 years ago #
  3. JC
    Member

    Thank you again Helga, I'm no good at logic, but your guessing was exact :
    This did the trick for me :

    // Put date first in postheader
    function childtheme_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"; 
    
      if (is_single()) { // only for single post
        $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate(); //the date first
        $postmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
        $postmeta .= thematic_postmeta_authorlink();
    
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
        }
    
        return $postmeta; 
    
    } // end childtheme_postheader_postmeta
    add_filter('thematic_postheader_postmeta', 'childtheme_postheader_postmeta');

    Cheers !

    Posted 3 years ago #
  4. Hi,

    this is pretty close to perfect .. without testing:

    // Put date first in postheader
    function childtheme_postheader_postmeta($postmeta) {
      if (is_single()) { // only for single post
        $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate(); //the date first
        $postmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
        $postmeta .= thematic_postmeta_authorlink();
    
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
        }
    
        return $postmeta; 
    
    } // end childtheme_postheader_postmeta
    add_filter('thematic_postheader_postmeta', 'childtheme_postheader_postmeta');

    This will keep the original already created data (see $postmeta in the function line), if it is not a single post. Otherwise it'll create your data. This code is a bit faster. :)

    Chris

    Posted 3 years ago #
  5. Hi,

    this is pretty close to perfect .. without testing:

    // Put date first in postheader
    function childtheme_postheader_postmeta($postmeta) {
      if (is_single()) { // only for single post
        $postmeta = '<div class="entry-meta">';
        $postmeta .= thematic_postmeta_entrydate(); //the date first
        $postmeta .= '<span class="meta-sep meta-sep-entry-date"> | </span>';
        $postmeta .= thematic_postmeta_authorlink();
    
        $postmeta .= thematic_postmeta_editlink();
    
        $postmeta .= "</div><!-- .entry-meta -->\n";
        }
    
        return $postmeta; 
    
    } // end childtheme_postheader_postmeta
    add_filter('thematic_postheader_postmeta', 'childtheme_postheader_postmeta');

    This will keep the original already created data (see $postmeta in the function line), if it is not a single post. Otherwise it'll create your data. This code is a bit faster. :)

    Chris

    Posted 3 years ago #
  6. JC
    Member

    Thank you Chris !
    As you noticed I'm no good at php, and I somehow had a feeling my code was uggly ;-)
    .. and it works great by the way !

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.