Welcome, guest!

Feel free to read the blog, browse for themes, or join the club.

How to remove Author name and in place put any name?

  1. Hi, my client needs to add posts from lots of other authors that are not WordPress users.

    For example change:
    By Mike Smith on February 17, 2010

    .... to:
    By Joe Blogs on February 17, 2010

    It means not been able to have the link to the WP author no more, but that is fine if just text because most posts with be by people who are not his users anyway.

    How best to make it easy for them to any author's name to byline? Could it be a custom field, and if so, how do I set that up in functions.php?

    Thanks for your time.

  2. You must be a logged-in exclusive member to view this reply.

  3. Thank you Justin for your reply.

    Just popped out to pick up my girl from school, and was thinking that would be the best way to do it too :)

    I would just create fake emails based on client's domain and that way the public can click on any author to view all their posts assigned to it.

    Kind regards, Ian

  4. Well now they tell me they need to have multiple authors per post, so kind of back to square one.

    This sounds like it might work, but do you see any likely conflicts with Hyrid News?
    http://wordpress.org/extend/plugins/co-authors-plus/other_notes/

    It sounds like I would need to change all the references to 'the_author' so could end up been a nightmare?

    You said I might be able to do something with functions instead.
    What I would like is eg:
    By Mike Smith on February 22, 2010

    ... to be able to include others and display like:
    By Mike Smith, Joe Blogs and Susan Black on February 17, 2010

    How would you suggest I could do this?

    If possible it would be good if their name linked to each user, but at this point, just having it as text would be better than only having one author as must be able to display one or more authors in one byline.

    Kind regards, Ian

  5. You must be a logged-in exclusive member to view this reply.

  6. Hi Justin, sorry for late reply, only got time to test it now. Was waiting on feedback from the other developer but his only works on php5 :(

    I tried the SP Authors plugin you mentioned with the filter code thanks. That worked but the links to the authors would display a 404 because they are using wrong links.

    The default links should be:
    http://www.site.org/author/amin_joanna/

    but the plugin was displaying the name as the link like:
    http://www.site.org/author/Joanna Lin/

    Is that something you might know how to fix?
    Also the other issue is that the multiple authors don't appear in sidebar articles or at bottom of post.

  7. I've just added a custom taxonomy called writer for co-authors on my blog. I'll be amending the byline in the next day or two to use this. It's a bit ugly but it's a viable solution so long as you don't need them to have permissions to edit posts. Just keep the entries in the custom taxonomy neat so it can map onto authors if necessary (or vice versa). It should build in some future-proofing.

    I really didn't want to use a PlugIn. I'm trying hard to keep my PlugIn count as low as possible.

    I think I may suggest support for co-authors as a standard feature in a future trunk release. In academic publishing co-authors is something that is an essential.

    Kate

  8. PS I now have it working in my site. http://egyptological.com/writer/kate-phizackerley is an example of an author (ie writer) page. (There are only two posts with author information set up - I'm still on test posts - so it's not very exciting.) It's a bit raw because there is no automatic gravatar, but it may fit your needs.

    Kate

  9. Hi Kate, thanks for your help.

    It sounds like it might work, but not sure I understand how you did it.
    I don't know about custom taxonomy?

    Do I just add some code to functions.php and how easy is it to assign multiple authors to a post?

    Kind regards, Ian

  10. Ian,

    Adding the custom taxonomy is easy. Justin has written some great tutiorials if you search, but this is the code to do it. Add it to functions.php

    add_action( 'init', 'create_my_taxonomies', 0 );
    
    function create_my_taxonomies() {
    	register_taxonomy( 'writer', 'post', array( 'hierarchical' => false, 'label' => 'Writer', 'query_var' => true, 'rewrite' => true ) );
    }

    Then refresh your admin panel. In the Posts menu you should now see Witer above Categories. Before you do anything else though, go to Settings, Permalinks and update your permalinks. No change is needed, just an update to refresh.

    You'll now see Writer between Tags and Categories when you edit posts. (You may prefer to change the label in the code to Writers.) It works just like tags so enter names of authors. IF you want a description, add it in the Writers panel in the Description field.

    In terms of displaying authors, you'll need to edit Justin's earlier code. I've not used the Byline section so I can't test what it will be for you but I think this should work (if not, Justin will I'm sure help tidy it up).

    add_filter( 'hybrid_byline', 'my_byline' );
    
    function my_byline( $byline ) {
    	global $post;
    
    	if ( 'post' == $post->post_type )
    		return '<p class="byline">[entry-terms taxonomy="writer" before="By "] on [entry-published] [entry-edit-link before=" | "]</p>';
    
    	return $byline;
    }

    If you have problems, then post again and I'll try to help

    Best wishes
    Kate

  11. You must be a logged-in exclusive member to view this reply.

  12. Hi Kate and Justin, thank you for your time.

    I have done the above but it does not display writers in By line. It just says:
    on February 25, 2010 | Edit

    It now says below post:
    Posted in Healthcare-Related Injuries, News & Notes | Tagged Joanna Lin, Matthew Richmond | Leave a comment

    fairwarning_org/tag/joanna-lin/

    This might be the better way to change it, as the 'Tagged' also appears in the sidebar under posts which the above code did not effect. If it could be moved out of that line and put above post and change 'Tagged' to 'By'

    Are any of you on Skype to help walk me through it?
    If so, my nickname is: pixelfreeway

  13. You must be a logged-in exclusive member to view this reply.

  14. Hi Ian
    I was worried about the Byline change as I couldn't test it. I replaced my 'Tagged' and don't display a Byline at all.

    So my piece of code to display the taxonomy is:

    add_filter( 'hybrid_entry_meta', 'halo_multiple_entry_meta' );
    
    function halo_multiple_entry_meta( $meta ) {
    	$meta = '<p class="entry-meta">[entry-terms taxonomy="writer" before="By "] </p><br>'; // Also removed [entry-comments-link before=" | "]
    	return $meta;
    }

    (I took out the Leave a Reply as well so save space as it isn't really needed on my site.)

    I've been working with WP for less than a month so Justin hopefuly will help iron out what's wrong. I'm a bit surprised by what you have posted though - it's almost as if your writer entries have been entered in Tags rather than the new Writer taxonomy. Any chance of a link - sometimes it's easier to see rather than try to visualise what you have?

    Kate

    (Sorry I am not in Skype. My ISP won't allow it.)

    @Justin
    As well as helping Ian, perhaps this would make a good post for your blog as adding co-authors is something that is often requested and avoiding a plug in really is better. Some shortcodes would allow people to add gravatars etc.
    K

  15. Sorry, my mistake, I did add them as default tags as I didn't see the Writer tag box just below. Great, I removed the tags from the Tag box and entered into the Writer box and they now appear :)

    By Joanna Lin, Matthew Richmond on February 25, 2010 | Edit

    I just need it to update on the sidebar as it still displays the author, not the writers.
    I used Query Posts to display exerpts there:

    fairwarning_org/tag/joanna-lin/
    (replace _ with a . for link to work, don't want indexed yet)

  16. You must be a logged-in exclusive member to view this reply.

  17. Ok thanks. How can I hide the author in the Query Posts then?
    So instead of:
    By Joanna Lin on February 25, 2010 | Edit

    it just says:
    February 25, 2010 | Edit

    Or if not possible then maybe just hide that whole line from the sidebar?

  18. Thanks for all your time.

    For now I have hidden the author from widget container with css (not ideal as the author link is still in source code so could get indexed by search engines but at least it doesn't display the wrong author for now)

    #widget-container .byline .text, #widget-container .byline .author { display: none }

    When there are multiple authors, would it be possible to somehow code it so say 'and' between the second and last writer?

    eg: By Mike Smith, Joe Blogs and Susan Black on February 17, 2010

  19. You must be a logged-in exclusive member to view this reply.

  20. Ian,
    I like your thinking. So I'm now using this instead:

    $writers = get_the_term_list($post->ID, 'writer', 'By ', ', ');
    $writers = preg_replace('/(.*),/', '$1 and', $writers);
    $meta = "<p class='entry-meta'>$writers</p>";

    (Care with the final line as I've swapped to double quotes as I prefer that format to concatenation where I loose track of the string delimiters.)

    If you can't work out how to make the changes to your code, post up what you have and I'll edit it for you.

    Kate

    @Justin - is there an filter that works on the Query Posts output that we could regex for Ian?

  21. Thanks Kate. I looked at your code and my code, and could not figure out where it was meant to go, so have included mine here. Thanks heaps:

    /* Multiple authors code */
    add_action( 'init', 'create_my_taxonomies', 0 );
    
    function create_my_taxonomies() {
    	register_taxonomy( 'writer', 'post', array( 'hierarchical' => false, 'label' => 'Writer', 'query_var' => true, 'rewrite' => true ) );
    }
    
    add_filter( 'hybrid_byline', 'my_byline' );
    
    function my_byline( $byline ) {
    	global $post;
    
    	if ( 'post' == $post->post_type )
    		return '<p class="byline">[entry-terms taxonomy="writer" before="By "] on [entry-published] [entry-edit-link before=" | "]</p>';
    
    	return $byline;
    }
  22. You must be a logged-in exclusive member to view this reply.

  23. You must be a logged-in exclusive member to view this reply.

  24. Fantastic Justin, works perfectly. For all interested, here's my full code:

    /* Multiple authors code */
    add_action( 'init', 'create_my_taxonomies', 0 );
    
    function create_my_taxonomies() {
     register_taxonomy( 'writer', 'post', array( 'hierarchical' => false, 'label' => 'Writer', 'query_var' => true, 'rewrite' => true ) );
    }
    
    add_filter( 'hybrid_byline', 'my_byline' );
    
    function my_byline( $byline ) {
     global $post;
    
     if ( 'post' == $post->post_type )
      return '<p class="byline">[co-authors before="By "] on [entry-published] [entry-edit-link before=" | "]</p>';
    
     return $byline;
    }
    
    add_shortcode( 'co-authors', 'my_co_authors_shortcode' );
    
    function my_co_authors_shortcode( $attr ) {
     global $post;
    
     $attr = shortcode_atts( array( 'before' => '', 'after' => '', 'separator' => ', ' ), $attr );
    
     $writers = get_the_term_list($post->ID, 'writer', $attr['before'], $attr['separator'], $attr['after'] );
     $writers = preg_replace('/(.*),/', '$1 and', $writers);
    
     return $writers;
    }

    Don't worry about the Query Posts issue for now. It is fine as I have hidden them with styles. If people do find a link to the list of posts by the default WordPress author, it's ok because all the posts still display the By line of the correct author anyway.

    Thanks so much for the time you both put in to it. I hope this will be of benefit of others in the Hybrid Community :)

  25. I prefer the shortcode option so I have swapped my code to use it too. Cheers Justin.

    While I was doinfg I generalised it further to add an option for the final separator. It defaults to ' and' but can now be over-ridden (eg if somebody prefers an ampersand). My revised shortcode code is:

    /* shortcode for co-authors */
    function my_co_authors_shortcode( $attr ) {
    	global $post;
    	$attr = shortcode_atts( array( 'before' => '', 'after' => '', 'separator' => ', ', 'final_separator' => ' and ' ), $attr );
    	$writers = get_the_term_list($post->ID, 'writer', $attr['before'], $attr['separator'], $attr['after'] );
    	$writers = preg_replace('/(.*),/', '$1' . $attr['final_separator'], $writers);
    	return $writers;
    }
  26. You must be a logged-in exclusive member to view this reply.

  27. I just found out that the 'wp-email' and 'wp-print' plugins display the default author still, and not the writers.

    How can I get these plugins to display the writers, instead of the default post author?

    I found the code in print-posts.php file, but not sure what to replace it with?
    <u><?php the_author(); ?></u>

    And in the 'wp-email.php' file this line which I think needs changing?
    $post_author = the_author('', false);

    I tried replacing it with text like 'writer', 'co-authors' or 'writers' that was in the functions.php but none of them worked, and just broke the print page.

    Could you help with what I need to do?
    Kind regards, Ian

  28. You must be a logged-in exclusive member to view this reply.

  29. Thank you, thank you, thank you :)

    Worked perfectly.
    Once again, you have helped me out.

Reply

You must log in to post.

Limited Access

If you have an account, please take a moment to log in.

Non-exclusive members have limited access to the support forums.

To enjoy the full range of support, sign up for an exclusive membership in the theme club.

Support Forums

  • Bliss Theme (253 posts)
  • Hybrid Theme (21,735 posts)
  • Options Theme (10,356 posts)
  • Structure Theme (2,747 posts)
  • Outline Theme (36 posts)
  • Visionary Theme (767 posts)
  • bbPress Themes (305 posts)
  • WordPress Plugins (2,045 posts)
  • General Discussion (5,276 posts)