Tagged: x
-
AuthorPosts
-
June 19, 2016 at 1:25 pm #1049424
How can I make the theme show the “about the author” under every blog post, and also have the author’s name under the title link to the page with the author’s posts (and preferably also with “about the author” there too?) Thanks!
June 19, 2016 at 1:27 pm #1049425Also: the website is http://www.socialup.it
June 19, 2016 at 4:04 pm #1049528Hi there,
Thanks for writing in! It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.
Thanks for understanding. Take care!
June 19, 2016 at 5:52 pm #1049608Hi, we’ve added some functions into the functions.php that has successfully added the author box on the bottom of the posts as well as the link to the author page (see: http://www.socialup.it/serenata-prima-delle-nozze/) with the author box on the top (see: http://www.socialup.it/author/polzella/)
However, we’ve searched around the forum for a way to make the name IN the author box be linked to the author’s page and the code doesn’t seem to work? This is the code we’ve put in:// Author - Add Author Page Link // ============================================================================= function x_shortcode_author_v2( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'title' => '', 'author_id' => '' ), $atts, 'x_author' ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-author-box cf ' . esc_attr( $class ) : 'x-author-box cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $title = ( $title != '' ) ? $title : __( 'About the Author', csl18n() ); $author_id = ( $author_id != '' ) ? $author_id : get_the_author_meta( 'ID' ); $description = get_the_author_meta( 'description', $author_id ); $display_name = get_the_author_meta( 'display_name', $author_id ); $facebook = get_the_author_meta( 'facebook', $author_id ); $twitter = get_the_author_meta( 'twitter', $author_id ); $googleplus = get_the_author_meta( 'googleplus', $author_id ); $author_url = get_author_posts_url( $author_id ); $facebook_output = ( $facebook ) ? "<a href=\"{$facebook}\" class=\"x-author-social\" title=\"Visit the Facebook Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i> Facebook</a>" : ''; $twitter_output = ( $twitter ) ? "<a href=\"{$twitter}\" class=\"x-author-social\" title=\"Visit the Twitter Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i> Twitter</a>" : ''; $googleplus_output = ( $googleplus ) ? "<a href=\"{$googleplus}\" class=\"x-author-social\" title=\"Visit the Google+ Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i> Google+</a>" : ''; $output = "<div {$id} class=\"{$class}\" {$style}>" . "<h6 class=\"h-about-the-author\">{$title}</h6>" . get_avatar( $author_id, 180 ) . '<div class="x-author-info">' . "<h4 class=\"h-author mtn\"><a href=\"{$author_url}\">{$display_name}</a></h4>" . $facebook_output . $twitter_output . $googleplus_output . "<p class=\"p-author mbn\">{$description}</p>" . '</div>' . '</div>'; return $output; } function change_author_shortcode_to_v2() { remove_shortcode( 'x_author' ); add_shortcode( 'x_author', 'x_shortcode_author_v2' ); } add_action('init', 'change_author_shortcode_to_v2');
is this incorrect?
June 19, 2016 at 5:54 pm #1049612This is to illustrate better what we’d like to link!
June 19, 2016 at 11:41 pm #1049981Hi there,
It should be working according to the code, unless, the custom code is not active. The only way to confirm that is to check it directly.
Would you mind providing your site’s Admin and FTP login credentials in private reply?
Thanks!
June 20, 2016 at 4:41 am #1050257This reply has been marked as private.June 20, 2016 at 6:36 am #1050425Hi,
Thank you for providing your login credentials.
In your code I can see you have modified [x_author] but you are using the [author] shortcode in adding it to your pages and posts.
Kindly change the code in #1049608 to this
// Author - Add Author Page Link // ============================================================================= function x_shortcode_author_v2( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'title' => '', 'author_id' => '' ), $atts, 'x_author' ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-author-box cf ' . esc_attr( $class ) : 'x-author-box cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $title = ( $title != '' ) ? $title : __( 'About the Author', csl18n() ); $author_id = ( $author_id != '' ) ? $author_id : get_the_author_meta( 'ID' ); $description = get_the_author_meta( 'description', $author_id ); $display_name = get_the_author_meta( 'display_name', $author_id ); $facebook = get_the_author_meta( 'facebook', $author_id ); $twitter = get_the_author_meta( 'twitter', $author_id ); $googleplus = get_the_author_meta( 'googleplus', $author_id ); $author_url = get_author_posts_url( $author_id ); $facebook_output = ( $facebook ) ? "<a href=\"{$facebook}\" class=\"x-author-social\" title=\"Visit the Facebook Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i> Facebook</a>" : ''; $twitter_output = ( $twitter ) ? "<a href=\"{$twitter}\" class=\"x-author-social\" title=\"Visit the Twitter Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i> Twitter</a>" : ''; $googleplus_output = ( $googleplus ) ? "<a href=\"{$googleplus}\" class=\"x-author-social\" title=\"Visit the Google+ Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i> Google+</a>" : ''; $output = "<div {$id} class=\"{$class}\" {$style}>" . "<h6 class=\"h-about-the-author\">{$title}</h6>" . get_avatar( $author_id, 180 ) . '<div class="x-author-info">' . "<h4 class=\"h-author mtn\"><a href=\"{$author_url}\">{$display_name}</a></h4>" . $facebook_output . $twitter_output . $googleplus_output . "<p class=\"p-author mbn\">{$description}</p>" . '</div>' . '</div>'; return $output; } function change_author_shortcode_to_v2() { remove_shortcode( 'x_author' ); remove_shortcode( 'author' ); add_shortcode( 'x_author', 'x_shortcode_author_v2' ); add_shortcode( 'author', 'x_shortcode_author_v2' ); } add_action('init', 'change_author_shortcode_to_v2');
Hope that helps.
June 20, 2016 at 7:50 am #1050513Hmm, it seems when we changed the code it removed the author box below the articles completely
June 20, 2016 at 7:54 am #1050523Ah nevermind, I copied it wrong! Now it works wonderfully! Thank you so much, always so helpful
June 20, 2016 at 8:10 am #1050545You’re welcome!
June 20, 2016 at 8:12 am #1050546One laaaast thing, is there any way to add the instagram link in About the Author? There doesn’t seem to be an option in the WordPress profile settings, would we have to do it manually for each author who wants to put their instagram link? (looking at the code here: https://community.theme.co/forums/topic/add-a-instagram-link-to-author-box-2/ )
June 20, 2016 at 9:07 am #1050634Hi,
To add instagram, you can change the code provided above with this.
// Author - Add Author Page Link // ============================================================================= function x_shortcode_author_v2( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'title' => '', 'author_id' => '' ), $atts, 'x_author' ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-author-box cf ' . esc_attr( $class ) : 'x-author-box cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $title = ( $title != '' ) ? $title : __( 'About the Author', csl18n() ); $author_id = ( $author_id != '' ) ? $author_id : get_the_author_meta( 'ID' ); $description = get_the_author_meta( 'description', $author_id ); $display_name = get_the_author_meta( 'display_name', $author_id ); $facebook = get_the_author_meta( 'facebook', $author_id ); $twitter = get_the_author_meta( 'twitter', $author_id ); $googleplus = get_the_author_meta( 'googleplus', $author_id ); $instagram = get_the_author_meta( 'instagram', $author_id ); $author_url = get_author_posts_url( $author_id ); $facebook_output = ( $facebook ) ? "<a href=\"{$facebook}\" class=\"x-author-social\" title=\"Visit the Facebook Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i> Facebook</a>" : ''; $twitter_output = ( $twitter ) ? "<a href=\"{$twitter}\" class=\"x-author-social\" title=\"Visit the Twitter Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i> Twitter</a>" : ''; $googleplus_output = ( $googleplus ) ? "<a href=\"{$googleplus}\" class=\"x-author-social\" title=\"Visit the Google+ Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i> Google+</a>" : ''; $instagram_output = ( $instagram ) ? "<a href=\"{$instagram}\" class=\"x-author-social\" title=\"Visit the Instagram Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-instagram-square\" data-x-icon=\"\"></i> Instagram</a>" : ''; $output = "<div {$id} class=\"{$class}\" {$style}>" . "<h6 class=\"h-about-the-author\">{$title}</h6>" . get_avatar( $author_id, 180 ) . '<div class="x-author-info">' . "<h4 class=\"h-author mtn\"><a href=\"{$author_url}\">{$display_name}</a></h4>" . $facebook_output . $twitter_output . $googleplus_output . $instagram_output . "<p class=\"p-author mbn\">{$description}</p>" . '</div>' . '</div>'; return $output; } function change_author_shortcode_to_v2() { remove_shortcode( 'x_author' ); remove_shortcode( 'author' ); add_shortcode( 'x_author', 'x_shortcode_author_v2' ); add_shortcode( 'author', 'x_shortcode_author_v2' ); } add_action('init', 'change_author_shortcode_to_v2'); add_action( 'show_user_profile', 'add_extra_social_links' ); add_action( 'edit_user_profile', 'add_extra_social_links' ); function add_extra_social_links( $user ) { ?> <h3>My Instagram Link</h3> <table class="form-table"> <tr> <th><label for="instagram_profile">Instagram Profile</label></th> <td><input type="text" name="instagram_profile" value="<?php echo esc_attr(get_the_author_meta( 'instagram_profile', $user->ID )); ?>" class="regular-text" /></td> </tr> </table> <?php } add_action( 'personal_options_update', 'save_extra_social_links' ); add_action( 'edit_user_profile_update', 'save_extra_social_links' ); function save_extra_social_links( $user_id ) { update_user_meta( $user_id,'instagram_profile', sanitize_text_field( $_POST['instagram_profile'] ) ); }
You can then enter your instagram link in your profile page.
Hope that helps.
June 25, 2016 at 5:42 am #1059137Hi! Sorry for the very late reply, our website was down so we weren’t able to get around to trying out the code until now… it doesn’t seem to have added the instagram option in the profile page
June 25, 2016 at 6:50 am #1059175Hi there,
Please try this one,
function x_shortcode_author_v2( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'title' => '', 'author_id' => '' ), $atts, 'x_author' ) ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-author-box cf ' . esc_attr( $class ) : 'x-author-box cf'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $title = ( $title != '' ) ? $title : __( 'About the Author', csl18n() ); $author_id = ( $author_id != '' ) ? $author_id : get_the_author_meta( 'ID' ); $description = get_the_author_meta( 'description', $author_id ); $display_name = get_the_author_meta( 'display_name', $author_id ); $facebook = get_the_author_meta( 'facebook', $author_id ); $twitter = get_the_author_meta( 'twitter', $author_id ); $googleplus = get_the_author_meta( 'googleplus', $author_id ); $instagram = get_the_author_meta( 'instagram', $author_id ); $author_url = get_author_posts_url( $author_id ); $facebook_output = ( $facebook ) ? "<a href=\"{$facebook}\" class=\"x-author-social\" title=\"Visit the Facebook Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-facebook-square\" data-x-icon=\"\"></i> Facebook</a>" : ''; $twitter_output = ( $twitter ) ? "<a href=\"{$twitter}\" class=\"x-author-social\" title=\"Visit the Twitter Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-twitter-square\" data-x-icon=\"\"></i> Twitter</a>" : ''; $googleplus_output = ( $googleplus ) ? "<a href=\"{$googleplus}\" class=\"x-author-social\" title=\"Visit the Google+ Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-google-plus-square\" data-x-icon=\"\"></i> Google+</a>" : ''; $instagram_output = ( $instagram ) ? "<a href=\"{$instagram}\" class=\"x-author-social\" title=\"Visit the Instagram Profile for {$display_name}\" target=\"_blank\"><i class=\"x-icon-instagram-square\" data-x-icon=\"\"></i> Instagram</a>" : ''; $output = "<div {$id} class=\"{$class}\" {$style}>" . "<h6 class=\"h-about-the-author\">{$title}</h6>" . get_avatar( $author_id, 180 ) . '<div class="x-author-info">' . "<h4 class=\"h-author mtn\"><a href=\"{$author_url}\">{$display_name}</a></h4>" . $facebook_output . $twitter_output . $googleplus_output . $instagram_output . "<p class=\"p-author mbn\">{$description}</p>" . '</div>' . '</div>'; return $output; } function change_author_shortcode_to_v2() { remove_shortcode( 'x_author' ); remove_shortcode( 'author' ); add_shortcode( 'x_author', 'x_shortcode_author_v2' ); add_shortcode( 'author', 'x_shortcode_author_v2' ); } add_action('init', 'change_author_shortcode_to_v2'); function add_profile_instagram ( $profile_fields ) { $profile_fields['instagram'] = 'Instagram URL'; return $profile_fields; } add_filter('user_contactmethods', 'add_profile_instagram');
It uses this filter https://codex.wordpress.org/Plugin_API/Filter_Reference/user_contactmethods
Hope this helps.
-
AuthorPosts