Tagged: x
-
AuthorPosts
-
November 29, 2016 at 12:23 pm #1274961
SabaconParticipantHi,
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
November 29, 2016 at 12:44 pm #1274982
RupokMemberHi 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!
November 29, 2016 at 4:52 pm #1275236
SabaconParticipantHi 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.
November 29, 2016 at 10:38 pm #1275565
RupokMemberHi 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.
November 30, 2016 at 10:46 am #1276168
SabaconParticipantHi,
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
November 30, 2016 at 10:59 am #1276182
ThaiModeratorHi 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: “%s”", '__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: “%s”", '__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: “%s”', '__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 🙂
November 30, 2016 at 1:22 pm #1276394
SabaconParticipantThank you, after installing this code, do I just use the author shortcode in cornerstone to get the authors to appear?
November 30, 2016 at 5:59 pm #1276669
Rue NelModeratorHello 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.
November 30, 2016 at 10:07 pm #1276952
SabaconParticipantExcuse my ignorance. The shortcode would be [coauthorbox].
November 30, 2016 at 10:14 pm #1276955
Rue NelModeratorHello 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.
December 1, 2016 at 12:10 am #1277059
SabaconParticipantJust one name. I can type the authors name in the post if need be.
December 1, 2016 at 12:18 am #1277063
Paul RModeratorHi,
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 credentialsDon’t forget to select Set as private reply. This ensures your information is only visible to our staff.
December 1, 2016 at 10:08 am #1277555
SabaconParticipantThis reply has been marked as private.December 1, 2016 at 10:29 am #1277587
SabaconParticipantHi,
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.
December 1, 2016 at 3:16 pm #1277924
RadModeratorHi 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!
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1274961 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
