WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
[resolved] Integrate Template Tags into Arras Theme (10 posts)

  1. earthsprite
    Member
    Posted 1 year ago #

    I already tried the Arras theme forums, but nobody's responded in a week. I'm having trouble figuring out WHERE to put the new template tag statements because Arras uses "filters.php" to display headers, bylines, etc. I know the snippet (as in, generally) where the coauthor tags need to go but I don't know how to write PHP conditionals/if statements appropriately...within other if statements.

    How should I modify this PHP?

    if ( !is_page() ) {
    		$postheader .= '<div class="entry-info">';
    
    		if ( arras_get_option('post_author') ) {
    			$postheader .= sprintf( __('<div class="entry-author">By %s</div>', 'arras'), '<address class="author vcard"><a class="url fn n" href="' . get_author_posts_url( get_the_author_meta('ID') ) . '" title="' . esc_attr(get_the_author()) . '">' . get_the_author() . '</a></address>' );
    		}

    The entirety of filters.php is here: http://code.google.com/p/arras-theme/source/browse/theme/trunk/library/filters.php?r=454 (lines 34-39)

    Thanks!

    http://wordpress.org/extend/plugins/co-authors-plus/

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    You can change this:

    $postheader .= sprintf( __('<div class="entry-author">By %s</div>', 'arras'), '<address class="author vcard"><a class="url fn n" href="' . get_author_posts_url( get_the_author_meta('ID') ) . '" title="' . esc_attr(get_the_author()) . '">' . get_the_author() . '</a></address>' );

    to something like this:

    $postheader .= sprintf( __('<div class="entry-author">By %s</div>', 'arras'), coauthors_posts_links( null, null, null, null, false) );

    Hope this helps

  3. earthsprite
    Member
    Posted 1 year ago #

    Thanks so much for the quick response. Unfortunately, that didn't work. It still shows the original author before the plugin and new coauthor. I deleted the original off of it, too.

    I'm using a child theme of Arras and that's where I'm really running into the trouble. I'm trying to follow http://forums.arrastheme.com/index.php?p=/discussion/comment/8294#Comment_8294 to override the parent functions...I'm getting errors with too many unexpected "{" etc. It's kind of a disaster.

    I'm starting to think Arras' setup is incompatible with your plugin (at least for those not fluent in PHP).

  4. darth73
    Member
    Posted 1 year ago #

    Hi earthsprite,

    To integrate Co-Author Plugin in Arras Theme, you musi change a function from filters.php (in arras/library folder) :

    Change :

    if ( arras_get_option('post_author') ) {
    			$postheader .= sprintf( __('<div class="entry-author">By %s</div>', 'arras'), '<address class="author vcard"><a class="url fn n" href="' . get_author_posts_url( get_the_author_meta('ID') ) . '" title="' . esc_attr(get_the_author()) . '">' . get_the_author() . '</a></address>' );
    		}

    By :

    if ( arras_get_option('post_author') ) {
    			if ( function_exists( 'coauthors_posts_links' )) {
    			$postheader .= sprintf( __('<div class="entry-author">By %s</div>', 'arras'), '<address class="author vcard"><a class="url fn n" href="' . get_author_posts_url( get_the_author_meta('ID') ) . '" title="' . esc_attr(get_the_author()) . '">' . coauthors_posts_links( null, null, null, null, false ) . '</a></address>' );
    			} else {
    			$postheader .= sprintf( __('<div class="entry-author">By %s</div>', 'arras'), '<address class="author vcard"><a class="url fn n" href="' . get_author_posts_url( get_the_author_meta('ID') ) . '" title="' . esc_attr(get_the_author()) . '">' . get_the_author() . '</a></address>' );
    		}}
  5. earthsprite
    Member
    Posted 1 year ago #

    Is it possible to do the above on a child theme so I don't have to modify Arras files (since I'll lose it when it updates)?

  6. darth73
    Member
    Posted 1 year ago #

    I don't know. For this, I've change original filters.php.
    I have a copy of classical gamer child theme and there are no filters.php in this child theme.

    Here, we change a function. Not add a new function.

    Try to create a new filters.php with the entire function post / page header code or a copy of original filters.php customized. If you have a error or if the function don't work, you must change original filters.php.

  7. earthsprite
    Member
    Posted 1 year ago #

    I tried both. For some reason a child filters.php won't override the parent's, even if you put it in the same file structure (library/filters.php). It does work if you directly edit the Arras filters.php. Totally against the point of child themes, but at least it works :(.

  8. earthsprite
    Member
    Posted 1 year ago #

    Uh oh. Looks like it'll take some extra work to implement Co-Authors into the bottom "About the Author" on single posts, too :(. If this weren't someone else's website I'd move to a simpler theme, yeesh.

    Here is the snippet from filters.php:

    function arras_post_aboutauthor() {
    	$id = get_the_author_meta('ID');
    
    	$output = '
    		<div class="about-author clearfix">
    			<a href="' . get_author_posts_url($id) . '">' . get_avatar($id, 64) . '</a>
    			<div class="author-meta">
    				<h4>' . sprintf(__('About %s', 'arras'),  get_the_author_meta('display_name')) . '</h4>
    			' . get_the_author_meta('description') . '
    			</div>
    		</div>
    	';
    
    	echo apply_filters('arras_post_aboutauthor', $output);
    }

    I tried this simple change by gary.d but it didn't work; it still called the original author and just lost its formatting.

    I assume I'll need another if statement here to get a co-author bio to show up :(. Thanks in advance.

  9. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    You should be good with something like this:

    function arras_post_aboutauthor() {
    	$id = get_the_author_meta('ID');
    
    	$output = '';
    	foreach( get_coauthors() as $coauthor ) {
    		$output .= '
    			<div class="about-author clearfix">
    				<a href="' . get_author_posts_url($coauthor->ID) . '">' . get_avatar($coauthor->ID, 64) . '</a>
    				<div class="author-meta">
    					<h4>' . sprintf(__('About %s', 'arras'),  $coauthor->display_name ) . '</h4>
    				' . $coauthor->description . '
    				</div>
    			</div>
    		';
    	}
    
    	echo apply_filters('arras_post_aboutauthor', $output);
    }
  10. earthsprite
    Member
    Posted 1 year ago #

    Thank you very much! That works.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic