ThemeShaper Forums » Thematic

[closed]

Remove "by author" from posts?

(14 posts)
  • Started 9 years ago by rgregory
  • Latest reply from psheld
  • This topic is resolved
  1. rgregory
    Member

    I have looked and google and searched the theme files for the_author(); code.

    Can anyone tell me what file to edit to remove the "by author" part of the post header?

    Thank you!

    Posted 9 years ago #
  2. Hey,

    try to include the following code into your child theme's functions.php:

    function remove_author($postmeta) {
        global $id, $post, $authordata;
    
        $author = '<span class="author vcard">';
        $author .= __('By ', 'thematic') . '<a class="url fn n" href="';
        $author .= get_author_link(false, $authordata->ID, $authordata->user_nicename);
        $author .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
        $author .= get_the_author();
        $author .= '</a></span><span class="meta-sep"> | </span>';
        $postmeta = str_replace($author, '', $postmeta);
        return $postmeta;
    }
    add_filter('thematic_postheader_postmeta', 'remove_author');

    Tested with Thematic 0.9 and the basic child theme coming from the directory thematic\thematic-sample-child-theme.

    Cheers,

    Chris

    Posted 9 years ago #
  3. rgregory
    Member

    Chris,

    Thank you so much, that worked fantasically. Please don't hate me, but I also updated to Thematic 0.9 when I added this code to the functions.php file.

    Can I add anything to take away the Published: part of the header as well?

    Should I start a new thread?

    Posted 9 years ago #
  4. No .. not as long as it is more or less the same subject :-)

    This would mean you want to remove the complete meta information (hope you don't mind that we remove the edit link too). Remove the above mentioned code from your child theme's functions.php and add the following code instead:

    function remove_meta() {
        return '';
    }
    add_filter('thematic_postheader_postmeta', 'remove_meta');

    Tested with Thematic 0.9 and the basic child theme coming from the directory thematic\thematic-sample-child-theme.

    Cheers,

    Chris

    Posted 9 years ago #
  5. rgregory
    Member

    Sorry Chris, I should have been more specific. I want only the date for these posts, I like it simple. :) (Don't worry, I will keep that remove_meta code handy for another project!)

    So,
    Post Name
    Date
    Then into the content.

    I really appriciate you taking the time to help with this.

    Posted 9 years ago #
  6. Ok :)

    function date_only() {
    		global $id, $post, $authordata;
    
        $postmeta = '<div class="entry-meta">';
        $postmeta .= '<span class="entry-date"><abbr class="published" title="';
        $postmeta .= get_the_time(thematic_time_title()) . '">';
        $postmeta .= get_the_time(thematic_time_display());
        $postmeta .= '</abbr></span>';
        // Display edit link -- uncomment the following 6 lines if you need the edit link
    
    //    if (current_user_can('edit_posts')) {
    //    		$posteditlink .= '<a href="' . get_bloginfo('wpurl') . '/wp-admin/post.php?action=edit&amp;post=' . $id;
    //    		$posteditlink .= '" title="' . __('Edit post', 'thematic') .'">';
    //    		$posteditlink .= __('Edit', 'thematic') . '</a>';
    //        $postmeta .= ' <span class="meta-sep">|</span> ' . $posteditlink;
    //    }
        $postmeta .= "</div><!-- .entry-meta -->\n";
    		return $postmeta;
    }
    add_filter('thematic_postheader_postmeta', 'date_only');

    Tested with Thematic 0.9 and the basic child theme coming from the directory thematic\thematic-sample-child-theme.

    Cheers,

    Chris

    Posted 9 years ago #
  7. rgregory
    Member

    Chris,

    Thank you so much. You have the patience of a saint, and are very generous with your time. I will try this out today after work.

    Just curios (this question is a learning opportunity for me so I have to come here with fewer questions), with a child them, isn't it usually the way to copy the file from the parent and change it and upload it to the child theme folder? Why do you recommend this function instead (which I am grateful for, I'm just trying to understand the relationship better)?

    Posted 9 years ago #
  8. While it's just as easy to copy a template file into your Child Theme directory if you can override something with a function it's going to make things easier in the long run when it comes time to upgrade.

    That said, sometimes you'll just want to copy the file and edit it.

    Posted 9 years ago #
  9. rgregory
    Member

    Ian, while I've got you here, where is the template file for $postmeta? I searched the thematic 0.9 folder and looked for author, which usually returns anything with author in the string. I couldn't find any file to work with.

    Posted 9 years ago #
  10. In this instance, filtering is really your only option as the info above and below the posts (title, cat links, etc.) is built in hooks-filters.php.

    Posted 9 years ago #
  11. thanks chris! I used your code. Am really trying to get the hang of hooks and filters, instead of directly changing the original thematic. i still suck at it, if i try writing code myself, but at least when i copy-paste your code it works :p

    cheers!

    Posted 9 years ago #
  12. HuskerLiz
    Member

    This worked for me, too. Thanks for your help.

    Posted 9 years ago #
  13. psheld
    Member

    Hi, I'm just getting to grips with Thematic hooks and filters... all good stuff, except none of the three functions listed in this thread work for me for some reason.

    I'm editing the functions.php of the child theme (Neutica+), inserting the chunks of code suggested above immediately after "<?php", but nothing changes at all to the site. I had envisaged hacking the code to my needs, but I have no place to start if nothing's working as is.

    Mmm. Could I be doing something really dumb. Possible! I felt sure the middle code above (the remove_meta function) was going to work.

    The beta for the site is hosted here at the moment fyi: http://newmeanwhile.atcv.net

    Any pointers in the right direction gratefully received.

    Posted 7 years ago #
  14. psheld
    Member

    Realised this thread is marked as resolved, so started afresh here:
    http://forums.themeshaper.com/topic/filter-thematic_postheader_postmeta

    Posted 7 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.