ThemeShaper Forums » Thematic

[closed]

Customizing thematic_postmeta_authorlink()

(6 posts)
  • Started 4 years ago by Relaxasaurus
  • Latest reply from jcollier
  • This topic is resolved
  1. Relaxasaurus
    Member

    Instead of saying "By author" I would like it to say "This post created by author"

    Added this to my functions.php file:

    =================

    function my_postmeta_authorlink() {
    
        global $authordata;
    
        $authorlink = '<span class="meta-prep meta-prep-author">' . __('This post created by ', 'thematic') . '</span>';
        $authorlink .= '<span class="author vcard">'. '<a class="url fn n" href="';
        $authorlink .= get_author_posts_url($authordata->ID, $authordata->user_nicename);
        $authorlink .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
        $authorlink .= get_the_author();
        $authorlink .= '</span>';
    
    } // end my_postheader_postmeta
    add_filter('thematic_postmeta_authorlink','my_postmeta_authorlink');

    =================

    Doesn't seem to change. Any tips? Thanks!

    Posted 4 years ago #
  2. Hi,

    you forgot:

    return $authorlink;

    at the end of your function.

    Chris

    Posted 4 years ago #
  3. I have been having the same problem filtering the following functions:

    • thematic_postmeta_authorlink
    • thematic_postmeta_entrydate
    • thematic_postmeta_editlink

    When I took a look at the source code in library\extensions\content-extensions.php and noticed that the apply_filters calls for each of these functions uses an extra underscore in the filter name. The filter names that currenty work are:

    • thematic_post_meta_authorlink
    • thematic_post_meta_entrydate
    • thematic_post_meta_editlink

    Hope this helps.

    Posted 3 years ago #
  4. Similar problem, now resolved by making the underscore from the previous post..

    I wanted to change "By" to "Posted by" in the authorlink. Used code below in child theme functions.php. Success

    // Function to change language in thematic_post_meta_authorlink
    
    function remove_oldpostmeta() {
    remove_action('thematic_postheader', 'thematic_post_meta_authorlink');
    }
    
    add_action('init', 'remove_oldpostmeta');
    
    function my_post_meta_authorlink() {
    
        global $authordata;
    
        $authorlink = '<span class="meta-prep meta-prep-author">' . __('Posted by ', 'thematic') . '</span>';
        $authorlink .= '<span class="author vcard">'. '<a class="url fn n" href="';
        $authorlink .= get_author_posts_url($authordata->ID, $authordata->user_nicename);
        $authorlink .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
        $authorlink .= get_the_author();
        $authorlink .= '</span>';
    
        return $authorlink;
    } 
    
    add_filter('thematic_post_meta_authorlink','my_post_meta_authorlink');
    Posted 3 years ago #
  5. In the code just above, what is the use of the function "remove_oldpostmeta" and "add_action"?

    I have tried the code without those lines, and it also works.

    Posted 3 years ago #
  6. Some time a while back, I was under the impression that functions had to be removed before they could be replaced. Maybe that is not true ...

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.