ThemeShaper Forums » Thematic


filtering childtheme_override_postheader_posttitle()

(4 posts)
  • Started 12 years ago by umberto
  • Latest reply from umberto
  • This topic is resolved
  1. umberto

    Hi,I'm converting a blog from Sandbox to thematic and wanting to use the subheading plug-in ( which requires this code in the template where the subheading goes:

    if (function_exists('the_subheading')) { the_subheading('<p>', '</p>'); }

    This was pretty straight forward in Sandbox by inserting in template.

    So I'm working towards filtering the thematic posttitle function but getting bogged down in the finer details.
    I have this so far:

    function childtheme_override_postheader_posttitle() {
    	    if (is_single() || is_page() && (function_exists('the_subheading'))) {
    	        $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
                    $posttitle .= the_subheading('<p class="subh">', '</p>');
    	    } elseif (is_404()) {
    	        $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
    	    } else {
    	        $posttitle = '<h2 class="entry-title"><a href="';
    	        $posttitle .= apply_filters('the_permalink', get_permalink());
    	        $posttitle .= '" title="';
    	        $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
    	        $posttitle .= '" rel="bookmark">';
    	        $posttitle .= get_the_title();
    	        $posttitle .= "</a></h2>\n";
    	    return $posttitle;

    which is not throwing up any errors, just not working.
    Tried previous filtering the postmeta with something like this:

    if(function_exists('the_subheading')) {
    	   $postmeta = '<div class="entry-meta">';
               $postmeta .= the_subheading('<p class="subh">', '</p>');
               $postmeta .= thematic_postmeta_entrydate();
    	   $postmeta .= thematic_postmeta_editlink();
    	   $postmeta .= "</div><!-- .entry-meta -->\n";

    with some success but for some reason wasn't ending up in the div.

    Pretty sure I'm missing some basic stuff :|

    I'm quite keen to get my head around the workings of the code but not sure where to look for info.
    for instance what does this little baby do:


    ...and what is the difference between
    = and .=

    Can someone point me to a resource where I can nut out those kinds of things?
    Any comments on the filter are also welcome.

    Enjoying thematic & exploring the forum


    Posted 12 years ago #
  2. you are defo missing some "basics". your first block has you calling the override and then using add_filter... which is crossing your wires. you either use the override OR you add_filter, not both.

    but i think you were closer w/ your 2nd block of code (which i presume was in a function).
    i think filtering will be easiest. i'd prolly filter thematic_postheader.... BUT the issue i "think" (only think b/c i am not looking at the plugin's code) I see is that the plugin ONLY echos out the value when you call the the_subheading() function. to use it with filters you need to return the value instead and idk if the plugin has a get_subheading() function.

    btw- "\n" means that the php will print a new line character (essentially a carriage return). those little things are tough to google.

    Posted 12 years ago #
  3. umberto

    Hey Thanks HtV - I'll have to hunt a little harder for an example to work from next time. Starting again! I'll report back when I have some success.

    Posted 12 years ago #
  4. umberto

    Solution from the plugin author:

    By default the_subheading() function will echo the value, but if you pass a third parameter of false, the value should be returned instead. Try changing it to the following:

    $postmeta = the_subheading('<p>', '</p>', false);

    Did the trick!

    Posted 12 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.