• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Working with multiple authors, how can I alter the output of the author's names?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Working with multiple authors, how can I alter the output of the author's names?

This topic is: not resolved

Tagged: .post-info, post_author_posts_link

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 6 months ago by Brad Dalton.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 15, 2016 at 3:02 pm #181479
    NWTD
    Member

    I'm using the Co-Author Plus plugin on my site -- in order for it to work on this framework, I'm using the Genesis Co-Author plugin, as well.

    I'm attempting to add more information to the output of the author, by using Advance Custom Fields. In the user's profile, I have a new field for their school/organization, in hopes that the output in the post info, will list the author(s) followed by their school/organization. I attempted to use after="{my code here}", to the shortcode [post_authors_post_link] that's used in the above mention plugin, but all it did was add my code to the end of the list of authors.

    I think that I need to attempt to alter the output of the [post_authors_post_link] shortcode with a foreach statement, and add my coding there for the Advanced Custom Fields.

    Here's the coding I'm trying to add to the end of the author's name:

    $author_id = get_the_author_meta('ID');
    
    if(get_field('school-organization', 'user_'. $author_id ){
         echo '<span>' . the_field('school-organization', 'user_'. $author_id ) . '</span>';
    }
    March 15, 2016 at 10:24 pm #181499
    Brad Dalton
    Participant

    1. You can take the original function for the post authors link and use it as a guide to create a custom shortcode which includes the value for your CF in the output..

    add_shortcode( 'post_author_posts_link', 'genesis_post_author_posts_link_shortcode' );
    
    function genesis_post_author_posts_link_shortcode( $atts ) {
    
    	$defaults = array(
    		'after'  => '',
    		'before' => '',
    	);
    
    	$atts = shortcode_atts( $defaults, $atts, 'post_author_posts_link' );
    
    	$author = get_the_author();
    	$url    = get_author_posts_url( get_the_author_meta( 'ID' ) );
    
    	if ( genesis_html5() ) {
    		$output  = sprintf( '<span %s>', genesis_attr( 'entry-author' ) );
    		$output .= $atts['before'];
    		$output .= sprintf( '', $url, genesis_attr( 'entry-author-link' ) );
    		$output .= sprintf( '<span %s>', genesis_attr( 'entry-author-name' ) );
    		$output .= esc_html( $author );
    		$output .= '</span>' . $atts['after'] . '</span>';
    	} else {
    		$link   = sprintf( '%s', esc_url( $url ), esc_html( $author ) );
    		$output = sprintf( '<span class="author vcard">%2$s<span class="fn">%1$s</span>%3$s</span>', $link, $atts['before'], $atts['after'] );
    	}
    
    	return apply_filters( 'genesis_post_author_posts_link_shortcode', $output, $atts );
    
    }
    

    Or

    2. Filter it using:

    genesis_post_author_posts_link_shortcode

    Tutorials for StudioPress Themes & WooCommerce.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble