Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1274961
    Sabacon
    Participant

    Hi,

    I have a post in which I need to have two authors. I used a plug-in called Co-Author Plus to allow me to input the two authors names on the post page. However, when I create the post in Cornerstone and used the Author shortcode, it only picks up the first name. Is there any way to pull both authors names? Is Co-Author Plus the right plugin/tool for the job or should I be using something else?

    G

    #1274982
    Rupok
    Member

    Hi there,

    As it’s not usual, the shortcode won’t bring two authors. You will need another plugin like the one you are using.

    Thanks!

    #1275236
    Sabacon
    Participant

    Hi Rupok,

    Help. I do not I understand. I have a plugin to get the two authors. I have the authors already. I need know if it is possible to get them into cornerstone.

    #1275565
    Rupok
    Member

    Hi there,

    Thanks for writing back. Unfortunately it’s not possible with the Author shortcode because it’s not usual. Let’s check if your plugin have any option to show the author info as well.

    Hope this makes sense.

    #1276168
    Sabacon
    Participant

    Hi,

    After some digging I found out that to integrate my plugin Co-Authors Plus, I’ll need to replace existing author template tags in the X theme with a simple conditional that uses the Co-Authors Plus template tags if Co-Authors Plus is available.

    For example, I need to update the_author_posts_link() to instead use coauthors_posts_links(): like:

    if ( function_exists (‘coauthors_posts_links’)) {
    coauthors_posts_links();
    } else {
    the_authors_posts_links();
    }

    and the_author() to instead use coauthors(): like:

    if ( function_exists (‘coauthors’)) {
    coauthors();
    } else {
    the_authors();
    }

    I have searched various php files to find the the_author() code to no avail. Could you tell which files for x-theme need updating? I checked single.php,page.php,index.php. Can I do this in my child theme?

    Thanks

    #1276182
    Thai
    Moderator

    Hi There,

    Please add the following code under functions.php file locates in your child theme:

    function x_integrity_entry_meta() {
    
    	//
    	// Author.
    	//
    
    	$the_author = function_exists('coauthors') ? coauthors(null, null, null, null, false) : get_the_author();
    
    	$author = sprintf( '<span><i class="x-icon-pencil" data-x-icon=""></i> %s</span>',
    	  $the_author
    	);
    
    	//
    	// Date.
    	//
    
    	$date = sprintf( '<span><time class="entry-date" datetime="%1$s"><i class="x-icon-calendar" data-x-icon=""></i> %2$s</time></span>',
    	  esc_attr( get_the_date( 'c' ) ),
    	  esc_html( get_the_date() )
    	);
    
    	//
    	// Categories.
    	//
    
    	if ( get_post_type() == 'x-portfolio' ) {
    	  if ( has_term( '', 'portfolio-category', NULL ) ) {
    	    $categories        = get_the_terms( get_the_ID(), 'portfolio-category' );
    	    $separator         = ', ';
    	    $categories_output = '';
    	    foreach ( $categories as $category ) {
    	      $categories_output .= '<a href="'
    	                          . get_term_link( $category->slug, 'portfolio-category' )
    	                          . '" title="'
    	                          . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
    	                          . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
    	                          . $category->name
    	                          . '</a>'
    	                          . $separator;
    	    }
    
    	    $categories_list = sprintf( '<span>%s</span>',
    	      trim( $categories_output, $separator )
    	    );
    	  } else {
    	    $categories_list = '';
    	  }
    	} else {
    	  $categories        = get_the_category();
    	  $separator         = ', ';
    	  $categories_output = '';
    	  foreach ( $categories as $category ) {
    	    $categories_output .= '<a href="'
    	                        . get_category_link( $category->term_id )
    	                        . '" title="'
    	                        . esc_attr( sprintf( __( "View all posts in: &ldquo;%s&rdquo;", '__x__' ), $category->name ) )
    	                        . '"><i class="x-icon-bookmark" data-x-icon=""></i> '
    	                        . $category->name
    	                        . '</a>'
    	                        . $separator;
    	  }
    
    	  $categories_list = sprintf( '<span>%s</span>',
    	    trim( $categories_output, $separator )
    	  );
    	}
    
    	//
    	// Comments link.
    	//
    
    	if ( comments_open() ) {
    
    	  $title  = apply_filters( 'x_entry_meta_comments_title', get_the_title() );
    	  $link   = apply_filters( 'x_entry_meta_comments_link', get_comments_link() );
    	  $number = apply_filters( 'x_entry_meta_comments_number', get_comments_number() );
    
    	  $text = ( 0 === $number ) ? 'Leave a Comment' : sprintf( _n( '%s Comment', '%s Comments', $number, '__x__' ), $number );
    
    	$comments = sprintf( '<span><a href="%1$s" title="%2$s" class="meta-comments"><i class="x-icon-comments" data-x-icon=""></i> %3$s</a></span>',
    	    esc_url( $link ),
    	    esc_attr( sprintf( __( 'Leave a comment on: &ldquo;%s&rdquo;', '__x__' ), $title ) ),
    	    $text
    	  );
    
    	} else {
    
    	  $comments = '';
    
    	}
    
    	//
    	// Output.
    	//
    
    	if ( x_does_not_need_entry_meta() ) {
    	  return;
    	} else {
    	  printf( '<p class="p-meta">%1$s%2$s%3$s%4$s</p>',
    	    $author,
    	    $date,
    	    $categories_list,
    	    $comments
    	  );
    	}
    
    }

    Hope it helps 🙂

    #1276394
    Sabacon
    Participant

    Thank you, after installing this code, do I just use the author shortcode in cornerstone to get the authors to appear?

    #1276669
    Rue Nel
    Moderator

    Hello There,

    Thanks for updating in! The given code will display coauthors and the authors link in the post meta and not the Author shortcode. The author box in Cornerstone was not design to support this plugin. I would recommend that you create a custom coauthor box shortcode instead. To do that, please make sure that you already have your child theme active and ready and insert this following code in your child theme’s functions.php file.

    // Add Co Author box below the single blog post
    // =============================================================================
    function add_coauthorbox(){ ?>
    
      <?php if ( function_exists( 'coauthors' ) ) : ?>  
      
      <div id="author-info">
        <?php $coauthors = get_coauthors(); ?>
        <?php foreach( $coauthors as $coauthor ) : ?>
          <div class="author-description">
          <?php $userdata = get_userdata( $coauthor->ID ); ?>
          <h2><?php if ( $userdata->display_name ) echo $userdata->display_name; ?></h2>
          <?php if ( $userdata->user_description ) echo $userdata->user_description; ?>
    
        <?php endforeach; ?>
      </div>
    
      <?php endif; ?>
    
    <?php }
    add_action('x_before_the_content_end', 'add_coauthorbox');
    // =============================================================================

    We would loved to know if this has work for you. Thank you.

    #1276952
    Sabacon
    Participant

    Excuse my ignorance. The shortcode would be [coauthorbox].

    #1276955
    Rue Nel
    Moderator

    Hello Again,

    Sorry for the typo error. There is no need for any shortcode because the code itself will display the coauthor box right after the post content. I will just rephrase it. To display the coauthor box right below the post, please make sure that you already have your child theme active and ready and insert this following code in your child theme’s functions.php file.

    // Add Co Author box below the single blog post
    // =============================================================================
    function add_coauthorbox(){ ?>
    
      <?php if ( function_exists( 'coauthors' ) ) : ?>  
      
      <div id="author-info">
        <?php $coauthors = get_coauthors(); ?>
        <?php foreach( $coauthors as $coauthor ) : ?>
          <div class="author-description">
          <?php $userdata = get_userdata( $coauthor->ID ); ?>
          <h2><?php if ( $userdata->display_name ) echo $userdata->display_name; ?></h2>
          <?php if ( $userdata->user_description ) echo $userdata->user_description; ?>
    
        <?php endforeach; ?>
      </div>
    
      <?php endif; ?>
    
    <?php }
    add_action('x_before_the_content_end', 'add_coauthorbox');
    // =============================================================================

    Please let us know how it goes.

    #1277059
    Sabacon
    Participant

    Just one name. I can type the authors name in the post if need be.

    #1277063
    Paul R
    Moderator

    Hi,

    Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    #1277555
    Sabacon
    Participant
    This reply has been marked as private.
    #1277587
    Sabacon
    Participant

    Hi,

    I realize this is getting extensive, but I need to have a way to turn this feature on and off. If this is getting to complicated, I can always write in the authors name in the post for now. The post with the two authors is The Thin book of Trust.

    #1277924
    Rad
    Moderator

    Hi there,

    Wordpress author works differently because each one represents an account. Yes, it’s complex since WordPress is made for single author only.

    You should contact the plugin author as I can’t really understand how their code works. If they instruction is just to add the shortcode, then you can use the_content filter to automatically add it on every post. The above codes are for post meta’s author which could be different from you wish to implement. Is it author box/card that appears below the content?

    Thanks!

  • <script> jQuery(function($){ $("#no-reply-1274961 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>