WordPress.org

Forums

Display Authors Twitter (10 posts)

  1. fouldsy99
    Member
    Posted 1 year ago #

    Hi all,

    I would like to display the authors twitter on the single page where it says By "Author".

    I have tried this code unsuccessfully:
    By <?php the_author_posts_link(); ?><?php the_author_meta('twitter'); ?>

    Any help how I can achieve this please?

    Regards

  2. C W
    Member
    Posted 1 year ago #

    There is no default twitter user meta field, so this snippet does nothing on its own. How are you creating the twitter field?

  3. fouldsy99
    Member
    Posted 1 year ago #

    I have twitter fields on profile section for JM Twitter Cards and WP to twitter plugin.

    At present, I am using this:

    By <?php the_author_posts_link(); ?> (<?php if ( get_the_author_meta( 'twitter' ) ) : ?>
    	<a href="<?php the_author_meta('twitter' );?>" target="_blank">Follow This Author On Twitter</a>
    <?php endif; ?>)

    Example

    Ideally I would like the "Follow This Author Twitter" to have the author's @twitter username displayed.

    Anyone know how?

  4. Joe Dolson
    Member
    Posted 1 year ago #

    If you're adding the author's Twitter handle to the user accounts using WP to Twitter's capabilities for that, it's stored in an author meta field named 'wp-to-twitter-user-username'.

  5. fouldsy99
    Member
    Posted 1 year ago #

    I already use wp-twitter, just would like to display on the article page the users twitter address who published the article.

    Example: By "Author" (@twitterusername)

  6. fouldsy99
    Member
    Posted 1 year ago #

    Here's how I got it now:

    (<?php if ( get_the_author_meta( 'twitter' ) ) : ?>
    	<a href="<?php the_author_meta('twitter' );?>" target="_blank">Follow On Twitter</a>
    <?php endif; ?>)

    I would just like to change the "Follow on Twitter" bit to show that users @twitterusername, the link works with going to the twitter page, just would like it display that username?

    Regards

  7. fouldsy99
    Member
    Posted 1 year ago #

    Just re-read your post Joe, worked a treat.

    <?php the_author_meta( 'wp-to-twitter-user-username' ); ?>

  8. Joe Dolson
    Member
    Posted 1 year ago #

    Cool. Glad you got it handled!

  9. fouldsy99
    Member
    Posted 1 year ago #

    Hi Joe,

    Ive recently run into some problems using that <?php the_author_meta( 'wp-to-twitter-user-username' ); ?>

    The full code I am using is: `<?php if ( get_the_author_meta( 'wp-to-twitter-user-username' ) ) : ?>
    (<a href="<?php the_author_meta('twitter' );?>" target="_blank">@<?php the_author_meta( 'wp-to-twitter-user-username' ); ?></a>)`

    However it doesn't seem be working right.

    I have two examples here:

    http://worldinsport.com/chris-tremlett-kevin-pietersen-was-just-voicing-his-opinion/ - works on here

    http://worldinsport.com/west-ham-united-v-manchester-united-match-review/ - but doesn't on here.

    Why would this be, for both user profiles I have a username on the WP Tweets User Settings on the edit profile page.

    I'm baffled about this one, any help please?

    Regards

  10. fouldsy99
    Member
    Posted 1 year ago #

    Problem solved, I somehow removed the // Add Twitter
    $contactmethods['twitter'] = 'Twitter';

    All done.

Topic Closed

This topic has been closed to new replies.

About this Topic