WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
CoAuthors and Woothemes Canvas (4 posts)

  1. shansmith01
    Member
    Posted 6 months ago #

    Hi I am trying to use CoAuthors with woothemes canvas.

    I have used co authors before but editing the template tags is proving difficult with canvas as it has a unique tagging system. Can i get a hand please?

    Cheers
    Shannon

    https://wordpress.org/plugins/co-authors-plus/

  2. eburnettw79
    Member
    Posted 5 months ago #

    Admittedly, probably better much ways to handle but think this will get you started. Opening the theme files (there are alot) author post meta is defined by /includes/theme-actions.php and /includes/theme-functions.php - this would be a quick and dirty to replace author info and avatars making use of the canvas > filters form and modifying the defined author archive condition by replacing woo pluggable function for archive title. Also adds post type support for portfolio - authors (so coauthors can be assigned). Note: coauthors must be active - does not deprecate.

    Dump all of this in your canvas theme functions.php file (under where it says - You can add custom functions below):

    // Custom shortcode function for coauthors post links
    
    function coauthor_links_shortcode( ) {
    
        if ( function_exists( 'coauthors_posts_links' ) ) {
            $author = coauthors_posts_links( null, null, null, null, false );
        } else {
           $author = '[post_author_posts_link]';
        }
        return  $author;
    }
    
    add_shortcode('author_links','coauthor_links_shortcode');
    
    // Define woo_post_meta if not set in filter yet
    
    function woo_post_meta() {
    
    	if ( is_page() && !( is_page_template( 'template-blog.php' ) || is_page_template( 'template-magazine.php' ) ) ) {
    		return;
    	}
    
    	$post_info = '<span class="small">' . __( 'By', 'woothemes' ) . '</span> [author_links] <span class="small">' . _x( 'on', 'post datetime', 'woothemes' ) . '</span> [post_date] <span class="small">' . __( 'in', 'woothemes' ) . '</span> [post_categories before=""] ';
    printf( '<div class="post-meta">%s</div>' . "\n", apply_filters( 'woo_filter_post_meta', $post_info ) );
    
    } // End woo_post_meta()
    
    // Replace Single Post Author (in theme-actions.php) 
    
    function woo_author_box () {
    	global $post;
    	$author_id=$post->post_author;
    
    	// Adjust the arrow, if is_rtl().
    	$arrow = '→';
    	if ( is_rtl() ) $arrow = '←';
    
    ?>
    <?php foreach( get_coauthors() as $coauthor ): ?>
    <aside id="post-author">
    	<div class="profile-image"> <?php echo coauthors_get_avatar( $coauthor, '80', '', false ); ?></div>
    	<div class="profile-content">
    		<h4><?php echo 'About '.$coauthor->display_name ?></h4>
    		<?php echo $coauthor->description; ?>
    		<?php if ( is_singular() ) { ?>
    		<div class="profile-link">
    			<a href="<?php echo get_author_posts_url( $coauthor->ID, $coauthor->user_nicename ); ?>">
    				<?php echo ('View all posts by: ' . $coauthor->display_name . '<span class="meta-nav">' . $arrow . '</span>' ); ?>
    			</a>
    		</div><!--#profile-link-->
    		<?php } ?>
    	</div>
    	<div class="fix"></div>
    </aside>
    <?php endforeach;
    } // End woo_author_box()
    
    // Replace Archive Titles conditions
    
    function woo_archive_title ( $before = '', $after = '', $echo = true ) {
    
    	global $wp_query;
    
    	if ( is_category() || is_tag() || is_tax() ) {
    
    		$taxonomy_obj = $wp_query->get_queried_object();
    		$term_id = $taxonomy_obj->term_id;
    		$taxonomy_short_name = $taxonomy_obj->taxonomy;
    
    		$taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name );
    
    	} // End IF Statement
    
    	$title = '';
    	$delimiter = ' | ';
    	$date_format = get_option( 'date_format' );
    
    	// Category Archive
    	if ( is_category() ) {
    
    		$title = '<span class="fl cat">' . __( 'Archive', 'woothemes' ) . $delimiter . single_cat_title( '', false ) . '</span> <span class="fr catrss">';
    		$cat_obj = $wp_query->get_queried_object();
    		$cat_id = $cat_obj->cat_ID;
    		$title .= '<a href="' . get_term_feed_link( $term_id, $taxonomy_short_name, '' ) . '" class="icon-rss icon-large" ></a></span>';
    
    		$has_title = true;
    	}
    
    	// Day Archive
    	if ( is_day() ) {
    
    		$title = __( 'Archive', 'woothemes' ) . $delimiter . get_the_time( $date_format );
    	}
    
    	// Month Archive
    	if ( is_month() ) {
    
    		$date_format = apply_filters( 'woo_archive_title_date_format', 'F, Y' );
    		$title = __( 'Archive', 'woothemes' ) . $delimiter . get_the_time( $date_format );
    	}
    
    	// Year Archive
    	if ( is_year() ) {
    
    		$date_format = apply_filters( 'woo_archive_title_date_format', 'Y' );
    		$title = __( 'Archive', 'woothemes' ) . $delimiter . get_the_time( $date_format );
    	}
    
    	// Author Archive
    	if ( is_author() ) {
    
    		$title = __( 'Author Archive', 'woothemes' ) . $delimiter . coauthors( null, null, null, null, true );
    	}
    
    	// Tag Archive
    	if ( is_tag() ) {
    
    		$title = __( 'Tag Archives', 'woothemes' ) . $delimiter . single_tag_title( '', false );
    	}
    
    	// Post Type Archive
    	if ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
    
    		/* Get the post type object. */
    		$post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
    
    		$title = $post_type_object->labels->name . ' ' . __( 'Archive', 'woothemes' );
    	}
    
    	// Post Format Archive
    	if ( get_query_var( 'taxonomy' ) == 'post_format' ) {
    
    		$post_format = str_replace( 'post-format-', '', get_query_var( 'post_format' ) );
    
    		$title = get_post_format_string( $post_format ) . ' ' . __( ' Archives', 'woothemes' );
    	}
    
    	// General Taxonomy Archive
    	if ( is_tax() ) {
    
    		$title = sprintf( __( '%1$s Archives: %2$s', 'woothemes' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name );
    
    	}
    
    	if ( strlen($title) == 0 )
    	return;
    
    	$title = $before . $title . $after;
    
    	// Allow for external filters to manipulate the title value.
    	$title = apply_filters( 'woo_archive_title', $title, $before, $after );
    
    	if ( $echo )
    		echo $title;
    	else
    		return $title;
    
    } // End woo_archive_title()
    
    // Add Custom Post Type Support args
    
    add_action('init', 'custom_post_type_support');
    function custom_post_type_support() {
    	add_post_type_support( 'portfolio', array('publicize','author') );
    	/* add_post_type_support( 'product', array('publicize','author') ); -- if adding coauthor box to woocommerce */
    
    }

    Then go into Canvas > Filters and change for both Post Meta and Portfolios:

    [post_author_posts_link]

    to

    [author_links]

    gl

  3. Dahbadu
    Member
    Posted 2 months ago #

    Hi eburnettw79,

    You're a life saver and are super awesome!

    There's a new problem though: When it takes you to the archive of a single author (e.g. bertrand-johnson), the header of the archive lists all the authors.

    For example: http://www.everythingisscrewed.com/author/bertrand-johnson/

    Any idea how to fix this?

    I guess I could use CSS to hide the entire header, but I'd like a more elegant solution.

  4. dminot
    Member
    Posted 3 weeks ago #

    I am using this with Canvas as well and just can't figure out some issues:

    1 - I have used the code provided by eburnettw79, but when you click on either of the coauthors, the archive page includes both authors' posts
    Here is a screenshot: http://i60.tinypic.com/bit101.jpg
    and the website is http://www.autismspectrumnews.org/author/russell-h-tobe-md/

    2 - There is a duplicate text of the authors name above just above the the heading for the Archive page. I don't know how to stop this from being generated.

    3 - Neither the email or website information are showing up.

    Any help with this would really be appreciated!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.