ThemeShaper Forums » Thematic


Add content to thematic_postheader_posttitle

(6 posts)
  • Started 11 years ago by crazybilly
  • Latest reply from Chris
  • This topic is not resolved
  1. I'm trying to add a bit of content to thematic_postheader_posttitle, but the filter I'm using doesn't seem to be having any affect whatsoever. After looking at this thread I pared down the function/filter to just postheader_posttitle (rather than all of postheader).

    Unfortunately, currently, I seem to be forcing the page into some sort of loop, or something--rather than output any code, the page takes a LONG time to load, then returns a blank page.

    Here's what I've got:

    function toughbubbles_postheader_posttitle() {
        global $id, $post, $authordata;
        if (is_single() || is_page()) {
            $posttitle = '<h1 class="entry-title">' . get_the_title() . "</h1>\n";
        } elseif (is_404()) {
            $posttitle = '<h1 class="entry-title">' . __('Not Found', 'thematic') . "</h1>\n";
        } else {
            $posttitle = '<h2 class="entry-title"><a href="';
            $posttitle .= get_permalink();
            $posttitle .= '" title="';
            $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
            $posttitle .= '" rel="bookmark">';
            $posttitle .= get_the_title();
            $posttitle .= "</a> yo </h2>\n";
            //I'll eventually remove the 'yo' in the above line and replace it with this:
            //$posttitle .= get_the_subheading(59,"<h3>","</h3>","false");
    	$posttitle = apply_filters('thematic_postheader_posttitle',$posttitle); 
    	return $posttitle;

    What am I doing wrong?

    Posted 11 years ago #
  2. Hi,

    remove the line:

    $posttitle = apply_filters('thematic_postheader_posttitle',$posttitle);


    Posted 11 years ago #
  3. Cool, that did it.

    Which gives me two questions:

    1. (so I can learn) why does the original function use apply_filters(), but the new one doesn't?

    2. for whatever reason, once I pull the "yo" out of that thing above and uncomment get_the_subheading(), the subheading appears ABOVE the post title, rather than below it. I used false for the last var of get_the_subheading, which is supposed to tell it not to display, but rather just return the value. Any ideas why's it's appearing first when it's later in the function?

    Thanks for your help!

    Posted 11 years ago #
  4. Hi,

    the apply_filter() is redundant. If you create something with the ability to be filtered you use apply_filter(). This opens the option to use a filter.

    If you create a filter, you write your function that does the filter job and use add_filter() outside of this function to connect the function to the filter hook.

    The call for get_the_subheading() should look like this:

    $posttitle .= get_the_subheading(59,"<h3>","</h3>",FALSE);

    Seems as if your function call echoes the result instead of return it.


    Posted 11 years ago #
  5. Ah, so the original apply_filters() creates the filter, and add_filter() actually applies my new filter (did I get that right?).

    I'll bet you're right about that FALSE value--I'm guessing "false" isn't good enough. I'll give it a go.

    Thanks for your help on this!

    Posted 11 years ago #
  6. Not exactly ;)

    - apply_filters() creates the filter hook.
    - you create the filter function
    - add_filter() connects your filter to the hook

    "false" is just a string .. FALSE is a boolean value.


    Posted 11 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.