ThemeShaper Forums » Thematic

[closed]

Adding multiple authors

(21 posts)
  • Started 5 years ago by neverknock
  • Latest reply from jgreenwood
  • This topic is not resolved

Tags:

  1. I'm stumped: I can't figure out how to use the "Co-author plus" plugin with in the Thematic-Acamas platform. It requires modifying code within template pages; however, the instructions are vague and don't correspond to the code I see in the templates. I'm grateful for any help you can provide. Thanks.

    Posted 5 years ago #
  2. Don't you have any alternative to this plugin??

    This plugins only echoes the results. You need something that returns a value.

    Chris

    Posted 5 years ago #
  3. Here are the three plugins I know about:

    http://www.techspikes.com/2009/04/assign-multiple-authors-to-blog-posts/

    I'm not aware of another way. And it seems this discussion says as much:

    http://wordpress.org/extend/ideas/topic.php?id=514

    Posted 4 years ago #
  4. mosesj
    Member

    Yes! I'm stumped with this problem, too. I'd be grateful if someone could help explain how to display co-authors within the Thematic framework.

    Best,
    Jacob

    Posted 4 years ago #
  5. .. will contact the plugin author to provide a function that returns the value.

    There's another way to do this right now, but this is not my favorite way to solve this problem.

    Chris

    Posted 4 years ago #
  6. mosesj
    Member

    Could I trouble you to explain the no-so-favorite solution? I'm on deadline for a project and can't figure out how to make co-authors and Thematic play nice.

    Thanks.

    Posted 4 years ago #
  7. I'm also interested in using the co-authors plus plugin. Unfortunately the plugin's functions do not seem to return a value, and so it doesn't look that easy to edit the thematic hooks-filter.php to return the multiple authors.

    Posted 4 years ago #
  8. Hi,

    take a look here: http://forums.themeshaper.com/topic/using-wp-postratings#post-1732

    The solution is similar.

    Will post the code for co-author plus later today.

    Chris

    Posted 4 years ago #
  9. Ok .. the code would be:

    function the_coauthor() {
    	ob_start();
    	coauthors_posts_links();
    	$content = ob_get_contents();
    	ob_end_clean();
    	return $content;
    }

    You might want to add some more data to coauthors_posts_links() (see its documentation). the_coauthor will return the needed data to filter entry-meta.

    Haven't tested this code. Please let me know if it works.

    Chris

    Posted 4 years ago #
  10. Where would you put this code if you are using your own child theme?

    Posted 4 years ago #
  11. mosesj
    Member

    I pasted the function in the functions.php file of my child theme, added "the_coauthors()" to my postheader, and it worked like a charm. Thanks so much!

    Posted 4 years ago #
  12. I pasted Chris' code as a function in my functions.php file in my child theme, and then copied and renamed the post header function, like in the guide. However, I am not sure where to put "the_coauthors()" in the customized post_header function.

    Posted 4 years ago #
  13. Without any warranty:

    Change the following code from Björn's guide:

    $postmeta .= '<span class="author vcard">';
        $postmeta .= __('By ', 'thematic') . '<a class="url fn n" href="';
        $postmeta .= get_author_link(false, $authordata->ID, $authordata->user_nicename);
        $postmeta .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
        $postmeta .= get_the_author();
        $postmeta .= '</a></span><span class="meta-sep"> | </span>';

    to:

    $postmeta .= '<span class="author vcard">';
        $postmeta .= __('By ', 'thematic');
        $postmeta .= the_coauthor();
        $postmeta .= '</span><span class="meta-sep"> | </span>';

    Chris

    Posted 4 years ago #
  14. This seems to work but when saving the post, I get the following error:

    Warning: Cannot modify header information - headers already sent by (output started at [mydomain child theme folder]/functions.php:103)in [mydomain]/wp-includes/pluggable.php on line 865

    The post shows up correctly in previews, but I get this error whenever I try to modify/save the post.

    Posted 4 years ago #
  15. No problem here.

    This is the code I used in my functions.php:

    function the_coauthor() {
    	ob_start();
    	coauthors_posts_links();
    	$content = ob_get_contents();
    	ob_end_clean();
    	return $content;
    }
    
    function my_postmeta() {
        global $id, $post, $authordata;
        $postmeta = '<div class="entry-meta">';
        $postmeta .= '<span class="meta-prep meta-prep-author">' . __('By ', 'thematic') . '</span>';
    	$postmeta .= '<span class="author vcard">';
        $postmeta .= the_coauthor();
        $postmeta .= '</span><span class="meta-sep"> | </span>';
        $postmeta .= '<span class="meta-prep meta-prep-entry-date">' . __('Published: ', 'thematic') . '</span>';
        $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
        if (current_user_can('edit_posts')) {
            $postmeta .= ' <span class="meta-sep meta-sep-edit">|</span> ' . '<span class="edit">' . $posteditlink . '</span>';
        }
        $postmeta .= "</div><!-- .entry-meta -->\n";
    	return $postmeta;
    }
    add_filter('thematic_postheader_postmeta', 'my_postmeta');

    Chris

    Posted 4 years ago #
  16. ... and thanks to childtheme overrides you can achieve that also like this:


    // support multiple authors using Co-Authors Plus plugin

    function childtheme_singleauthorlink () {
    global $authordata;
    $result = '<span class="author vcard">'. '<a class="url fn n" href="';
    $result .= get_author_posts_url($authordata->ID, $authordata->user_nicename);
    $result .= '" title="' . __('View all posts by ', 'thematic') . get_the_author() . '">';
    $result .= get_the_author();
    $result .= '</span>';
    return $result;
    }

    function childtheme_override_postmeta_authorlink() {

    $i = new CoAuthorsIterator();

    if(function_exists('coauthors_posts_links')) {
    $authorlink = '<span class="meta-prep meta-prep-author">' . _n('Author ', 'Authors ', $i->count(), 'childtextdomain') . '</span>';
    $i->iterate();
    $authorlink .= childtheme_singleauthorlink ();
    while($i->iterate()){
    if (!$i->is_last()) $authorlink .= ', ';
    else $authorlink .= __(' and ', 'childtextdomain');
    $authorlink .= childtheme_singleauthorlink ();
    }
    $authorlink .= '</span>';

    }
    else {
    $authorlink = '<span class="meta-prep meta-prep-author">' . __('By ', 'thematic') . '</span>';
    $authorlink .= childtheme_singleauthorlink ();
    }

    return apply_filters('thematic_post_meta_authorlink', $authorlink);
    }

    Posted 3 years ago #
  17. @Chris

    Your functions.php snippet works for me! Thank you very much.

    But, it does not apply the link styles to the_coauthor(), namely the class="url fn n".

    Also, the post 'Edit' link does not appear after the '|' character.

    Thanks for any insight!

    Cheers,
    Joe

    Posted 3 years ago #
  18. Actually I decided to stop using this plugin ... thanks anyway. Cheers!

    Posted 3 years ago #
  19. So my next thought is, can additional authors be added to a post using custom fields and then displayed publicly using thematic_post_meta_authorlink? Without using any plugin. If anyone knows this, please speak up! If I get it figured out, I will of course share my solution. Thanks!

    Posted 3 years ago #
  20. Sweet, I've got the core functionality figured out, at least. I need to add style and also would like to make coauthors names link to their additional posts, but this keeps me publishing for yet another day and I can figure the rest out with time.

    NOTE this does NOT use the PLUGIN mentioned at start of this thread. This uses no plugin whatsoever, only added this inside my child theme's functions.php and use "Coauthors" as the name of the custom field in the posts.

    //  add additional authors to posts where "Coauthors" is the custom field
    function my_post_meta_authorlink() {
    
    	    global $authordata, $post;
    
       $coauthor = get_post_meta ($post->ID, 'Coauthors', true);
    	    $authorlink = '<span class="meta-prep meta-prep-author">' . __('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_meta( 'display_name' ) . '">';
    	    $authorlink .= get_the_author_meta( 'display_name' );
    	    $authorlink .= '</a>';
    	if ($coauthor) {   $authorlink .= ', ' . $coauthor;  }
    	    $authorlink .= '</span>';
    
        return $authorlink;
    
    } 
    
    add_filter('thematic_post_meta_authorlink','my_post_meta_authorlink');

    Also please note there is likely some more efficient way of doing this; I am just a learn-as-I-go PHP guy, and this is working for me right here and now. Improvement suggestions very welcome!

    Cheers

    Posted 3 years ago #
  21. Ah, the linking and styling was easier than expected; just use the $coauthors variable to fill in the link address and title blank spots, all wrapped in the appropriate span and link css class

    //  add additional authors to posts
    function my_post_meta_authorlink() {
    
    	    global $authordata, $post;
    
       $coauthor = get_post_meta ($post->ID, 'Coauthors', true);
    	    $authorlink = '<span class="meta-prep meta-prep-author">' . __('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_meta( 'display_name' ) . '">';
    	    $authorlink .= get_the_author_meta( 'display_name' );
    
    	    $authorlink .= '</a>';
    	if ($coauthor) {   $authorlink .= ' and <span class="author vcard"><a class="url fn n" href="/author/' . $coauthor . '" title="View all posts by ' . $coauthor . '">' . $coauthor . '</a></span>';  }
    	    $authorlink .= '</span>';
    
        return $authorlink;
    
    } 
    
    add_filter('thematic_post_meta_authorlink','my_post_meta_authorlink');
    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.