ThemeShaper Forums » Thematic

how to return a filter AND add a wp function

(6 posts)
  • Started 5 years ago by cathy
  • Latest reply from cathy
  • This topic is not resolved
  1. Goal - to put a (# of comments link underneath post title in the postmeta area. I have been trying thru trial and error to get this right based on Chris's articles on the blog - but I cannot get it right!!

    [php]//add comment link beneath title

    function childtheme_postmeta($postmeta) {

    return $postmeta;
    $postmeta .= comments_number('no responses','one response','% responses');

    add_filter('thematic_postheader_postmeta', 'childtheme_postmeta');[/php]


    Posted 5 years ago #
  2. amygail

    Cathy - off the bat - the php tags are incorrect.
    they should be open like this <?php
    and close like this ?>

    look at this post for an example of how to write functions

    Posted 5 years ago #
  3. Thank you amygail,

    I had used [php] 'tags' like a wiki instead of backtick tags like a bb! Oops :)

    I have looked at every piece of code in the wiki/ and the how to customize blogs too... For some reason (that reason being that I don't know php) I can't figure this one out! Something to do with the "return" of the existing data, and then somehow adding to the items. Any thoughts?

    Posted 5 years ago #
  4. Don't throw the code into your blender :)

    First: Filter $postmeta.

    Second: Return $postmeta.

    Will be back in a minute .. need to check one thing on my other machine.


    Posted 5 years ago #
  5. .. and I would add a bit markup:

    //add comment link beneath title
    function childtheme_postmeta($postmeta) {
        // add the separator
        $postmeta .= ' <span class="meta-sep meta-sep-edit">|</span> ';
        // add the additional markup
        $postmeta .= '<span class="meta-comments-number">';
        // add the comments_number
        $postmeta .= comments_number('no responses','one response','% responses');
        // close the markup
        $postmeta .= '</span>';
        // finally return $postmeta
        return $postmeta;
    add_filter('thematic_postheader_postmeta', 'childtheme_postmeta');

    Haven't tested this code ..


    Posted 5 years ago #
  6. This replaced the entire page (under the header) with "Comments (nn)" for each post...

    And by the way, that wasn't a blender, that was my brain. One & the same perhaps?

    Posted 5 years ago #

RSS feed for this topic


You must log in to post.