• 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: https://midwayjournal.com/test/

    https://www.ads-software.com/extend/plugins/co-authors-plus/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Daniel Bachhuber

    (@danielbachhuber)

    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.

    Thread Starter hazelstreet

    (@hazelstreet)

    Thank you very much! This did the trick.

    Thread Starter hazelstreet

    (@hazelstreet)

    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: https://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;
    }
    
    ?>
    Thread Starter hazelstreet

    (@hazelstreet)

    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.

    Thread Starter hazelstreet

    (@hazelstreet)

    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!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘No longer working after I customized my theme's byline’ is closed to new replies.