WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
No longer working after I customized my theme's byline (6 posts)

  1. hazelstreet
    Member
    Posted 1 year ago #

    Hi, I new to PHP, but trying to create a child theme in order to tweak some things necessary for a website I'm working on. I installed this plugin and it worked great with my theme, until I created a custom byline. Now the posts all appear as written by "Administrator", rather than by their guest authors.

    Here's the code I added to my child theme's function.php file to create the new custom byline:

    <?php
    
    add_action( 'after_setup_theme', 'midwayjournal_setup', 11 );
    
    function midwayjournal_setup() {
    
    	/* Get the parent theme prefix. */
    	$prefix = hybrid_get_prefix();
    
    	/* Actions and filters calls go here in the future. */
    	add_filter( "{$prefix}_byline", 'midwayjournal_byline' );
    
    }
    
    /**
     * Function to output the author byline but no date.
     *
     */
    
    function midwayjournal_byline( $byline ) {
    
    	if ( 'post' === get_post_type() )
    		$byline = '<div class="byline">Written by [entry-author]</div>';
    
    	return $byline;
    }
    
    ?>

    Maybe it's just as simple as replacing whatever Co-Authors Plus uses to call the byline with my new custom byline "name"? But I have no idea what I'm really looking for.

    Thanks for any help!
    The work-in-progress site in question: http://midwayjournal.com/test/

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

  2. Daniel Bachhuber
    Hand Built
    Plugin Author

    Posted 1 year ago #

    Try changing this:

    $byline = '<div class="byline">Written by [entry-author]</div>';

    to this:

    $byline = '<div class="byline">Written by ' . coauthors_posts_links( null, null, null, null, false ) . '</div>';

    [entry-author] is a shortcode your theme uses to display the post author information. Co-Authors Plus is doing a bit of trickiness behind the scenes to let you use guest authors, so you need to use the Co-Authors Plus template tag.

  3. hazelstreet
    Member
    Posted 1 year ago #

    Thank you very much! This did the trick.

  4. hazelstreet
    Member
    Posted 1 year ago #

    Hi again -- I am picking this project back up after a hiatus.

    Your suggested fix worked great in terms of it appearing as it should on the public side... but the new code in my child functions.php file locked me out of the WP dashboard/controls (when I try to log in, I enter the login info, and then I just get a blank white screen and nothing else).

    Is it possible that this could be a syntax issue, or something else that I could tweak in the functions file to both get it running, and let me log into the site?

    I'll copy my child theme functions.php file here again (the version that broke the WP login).

    Thank you for any help!!
    The work-in-progress site in question: http://midwayjournal.com/test/

    Child theme functions.php file:

    <?php
    
    add_action( 'after_setup_theme', 'midwayjournal_setup', 11 );
    
    function midwayjournal_setup() {
    
    	/* Get the parent theme prefix. */
    	$prefix = hybrid_get_prefix();
    
    	/* Actions and filters calls go here in the future. */
    	add_filter( "{$prefix}_byline", 'midwayjournal_byline' );
    
    }
    
    /**
     * Function to output the author byline but no date.
     *
     */
    
    function midwayjournal_byline( $byline ) {
    
    	if ( 'post' === get_post_type() )
    		$byline = '<div class="byline">by ' . coauthors_posts_links( null, null, null, null, false ) . '</div>';
    
    	return $byline;
    }
    
    ?>
  5. hazelstreet
    Member
    Posted 1 year ago #

    P.S. I've removed the offending child theme functions.php file from the site until this is resolved so that I can get back into the dashboard -- so if you visit it, you'll see "Administrator" listed as the post authors, since Co-Authors Plus isn't currently working without the functions fix.

  6. hazelstreet
    Member
    Posted 1 year ago #

    Err, when I said "you'll see 'Administrator' listed as the post authors..." above, I was wrong -- what you'll see is a working Co-Authors Plus, just with the default byline (which I would like to edit... so then I created the custom byline, and Co-Authors Plus broke, which started this whole thread). I removed the offending child theme functions.php file, which has removed both the custom byline and Daniel's suggested fix.

    I would edit the above post, but it doesn't seem to allow me to... just wanted to clarify in case that point confused anyone trying to figure out the problem. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.