Community Forums › Forums › Archived Forums › General Discussion › How to change post info author links to my Gplus with vcard?
This topic is: not resolved
Tagged: .post-info, Author, author link
- This topic has 1 reply, 2 voices, and was last updated 6 years, 4 months ago by
Brad Dalton.
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
May 21, 2017 at 7:17 am #206784
ictiempo
MemberHi,
I just change my theme to Genesis but I found it hard to change the author links to my google plus with vcard. Any help will be appreciated.
https://www.techchore.com/May 22, 2017 at 5:25 am #206796Brad Dalton
ParticipantHi
Generally, the author link goes to a page with posts from the author, not an external link however it can be done.
If you're up for coding, you can copy one of the functions from Genesis and modify or filter it.
Note : Happy to point you in the right direction however this code modification and testing would take some time and is not covered here today.
add_shortcode( 'post_author_link', 'genesis_post_author_link_shortcode' ); /** * Produces the author of the post (link to author URL). * * Supported shortcode attributes are: * after (output after link, default is empty string), * before (output before link, default is empty string). * * Output passes through
genesis_post_author_link_shortcode
filter before returning. * * @since 1.1.0 * * @param array|string $atts Shortcode attributes. Empty string if no attributes. * @return string Return empty string if post type does not supportauthor
or post has no author assigned. * Returngenesis_post_author_shortcode()
if author has no URL. * Otherwise, output forpost_author_link
shortcode. */ function genesis_post_author_link_shortcode( $atts ) { if ( ! post_type_supports( get_post_type(), 'author' ) ) { return ''; } $url = get_the_author_meta( 'url' ); // If no URL, use post author shortcode function. if ( ! $url ) { return genesis_post_author_shortcode( $atts ); } $author = get_the_author(); if ( ! $author ) { return ''; } $defaults = array( 'after' => '', 'before' => '', ); $atts = shortcode_atts( $defaults, $atts, 'post_author_link' ); if ( genesis_html5() ) { $output = sprintf( '<span %s>', genesis_attr( 'entry-author' ) ); $output .= $atts['before']; $output .= sprintf( '', $url, genesis_attr( 'entry-author-link' ) ); $output .= sprintf( '<span %s>', genesis_attr( 'entry-author-name' ) ); $output .= esc_html( $author ); $output .= '</span>' . $atts['after'] . '</span>'; } else { $link = '' . esc_html( $author ) . ''; $output = sprintf( '<span class="author vcard">%2$s<span class="fn">%1$s</span>%3$s</span>', $link, $atts['before'], $atts['after'] ); } return apply_filters( 'genesis_post_author_link_shortcode', $output, $atts ); } add_shortcode( 'post_author_posts_link', 'genesis_post_author_posts_link_shortcode' ); /** * Produces the author of the post (link to author archive). * * Supported shortcode attributes are: * after (output after link, default is empty string), * before (output before link, default is empty string). * * Output passes throughgenesis_post_author_posts_link_shortcode
filter before returning. * * @since 1.1.0 * * @param array|string $atts Shortcode attributes. Empty string if no attributes. * @return string Return empty string if post type does not supportauthor
or post has no author assigned. * Otherwise, output forpost_author_posts_link
shortcode. */ function genesis_post_author_posts_link_shortcode( $atts ) { if ( ! post_type_supports( get_post_type(), 'author' ) ) { return ''; } $author = get_the_author(); if ( ! $author ) { return ''; } $defaults = array( 'after' => '', 'before' => '', ); $atts = shortcode_atts( $defaults, $atts, 'post_author_posts_link' ); $url = get_author_posts_url( get_the_author_meta( 'ID' ) ); if ( genesis_html5() ) { $output = sprintf( '<span %s>', genesis_attr( 'entry-author' ) ); $output .= $atts['before']; $output .= sprintf( '', $url, genesis_attr( 'entry-author-link' ) ); $output .= sprintf( '<span %s>', genesis_attr( 'entry-author-name' ) ); $output .= esc_html( $author ); $output .= '</span>' . $atts['after'] . '</span>'; } else { $link = sprintf( '%s', esc_url( $url ), esc_html( $author ) ); $output = sprintf( '<span class="author vcard">%2$s<span class="fn">%1$s</span>%3$s</span>', $link, $atts['before'], $atts['after'] ); } return apply_filters( 'genesis_post_author_posts_link_shortcode', $output, $atts ); }
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
- The forum ‘General Discussion’ is closed to new topics and replies.