ThemeShaper Forums » Thematic

[closed]

My code used for filtering the post title doesn't work

(7 posts)
  • Started 4 years ago by gattonero
  • Latest reply from gattonero
  • This topic is not resolved
  1. Hi buddies,
    sorry to bother you again but the more I go into Thematic, the more I understand, the more I have unexpected results ;)

    I've learned the existence of the filters. And that's so much fun, and so much good.
    But there must be something wrong in my code, 'cause it doesn't wor properly. Could you help me understand, maybe?

    What I want to do is to add post thumbnails and change a bit the order of the elements of the posttitle...

    Here's my code:

    function cm_postheader_posttitle() {
    	    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 = '<div class="testatapost">';
            $posttitle .= the_post_thumbnail();
            $posttitle .= '<a href="';
            $posttitle .= get_permalink();
            $posttitle .= '" title="';
            $posttitle .= __('Permalink to ', 'thematic') . the_title_attribute('echo=0');
            $posttitle .= '" rel="bookmark"><div class="entry-title">';
            $posttitle .= '<h2>';
            $posttitle .= get_the_title();
            $posttitle .= '</h2><span class="entry-excerpt">';
            $posttitle .= get_the_excerpt();
            $posttitle .= "</span></div></a></div>\n";
        }
    }
    
    add_filter('thematic_postheader_posttitle', 'cm_postheader_posttitle');

    The problem is that, as a result, I get *only* the thumbnail image and nothing more (not even the
    <div class="testatapost">
    that is before the command to call the thumbnail.

    Any idea?

    Posted 4 years ago #
  2. (I tried get_the_post_thumbnail but as a result I get *nothing*...)

    Posted 4 years ago #
  3. You are not returning anything inside the function.

    return apply_filters('cm_postheader_posttitle',$posttitle);

    Artur Kim

    Posted 4 years ago #
  4. So stupid... thanks :)
    (Don't know why I deleted that code...)

    Posted 4 years ago #
  5. You're welcome!

    Posted 4 years ago #
  6. ;)

    It seems I have to use your help again. I've quite understood that - differently from "normal" themes - knowing HTML and CSS is not enough to properly use and adapt Thematic.
    You need to know PHP too, and in a good way.

    I'd need to "filter" thematic_content(), to have included this code *before* what we classically called with the_content():

    <div class="addtoany_share_save_container"><?php if( function_exists('ADDTOANY_SHARE_SAVE_KIT') ) { ADDTOANY_SHARE_SAVE_KIT(); } ?></div>

    But I'm not able to. Could you help me?
    (I'm a fast learner: using filters is a HUGE facilitation to Thematic modification).

    Posted 4 years ago #
  7. (I've resolved the problem with a workaround, but the question remains for an educational purpose ;) )

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.