Display a link to the author's twitter account

Posted in: Newsmag
Post count: 16

I would like to modify the following lines of code, taken from Version 2.1 of NewsMag theme.

My intention is to add a link to the post author’s twitter account, instead of the usual link to their post archives.

I am editing line 66 to 78 of the file ‘td_module_single_base.php’ in ‘includes/wp_booster’.

I have tried to use the WordPress function get_the_author_meta(‘twitter’, $author_id) as follows, but I cannot get it to work with the way the code has been concatenated.

Any help would be appreciated.

Here is the non-functioning code:

$buffy .= ‘‘ . get_the_author_meta(‘display_name’, $this->post->post_author) . ‘‘ ;

EDIT : I can’t display the code correctly, but the line I wish to show is line 70.

  • This topic was modified 10 years by Andrex. Reason: Using the code tags didn't work!
  • This topic was modified 10 years by Andrex.
  • This topic was modified 10 years by Andrex.
  • This topic was modified 10 years by Andrex.
  • This topic was modified 10 years by Andrex.
  • This topic was modified 10 years by Andrex.
  • This topic was modified 10 years by Andrex.
Post count: 6535

Hi

You can directly add your twiter link in that function like here: http://screencast.com/t/3e9BXQqfhttp://screencast.com/t/Qv5hxIaQ23 Also you can try using this function: get_the_author_meta( 'twitter')

Thanks!

Post count: 16

Manually adding the whole link does not work, since each individual author will have their own twitter account – the intention is not to link it to the site’s main twitter account.

I have also already included get_the_author_meta('twitter') to no avail – it does not work within the way this code has been constructed.

You can see my code here: http://touringcars.net/Screengrab-td_module_single_base.png – this just adds a link to ‘https://www.twitter.com’, but I’d like it to link to ‘https://www.twitter.com/TWITTER USERNAME’.

Can you offer any other solutions? I#m sure this should be a fairly minor issue.

Thanks for your help

  • This reply was modified 10 years by Andrex. Reason: Thank you
Post count: 6535

Hi

Replace the indicated line of code with this one: http://screencast.com/t/35EQKm4SguM

$buffy .= '<a href="' . get_the_author_meta('twitter', $this->post->post_author) . '">' . get_the_author_meta('display_name', $this->post->post_author) . '</a>' ;

You have to add your twitter link at user profile like this: http://screencast.com/t/rcGmxQxp The result should be like here: http://screencast.com/t/IVLCKWfpIu

Let me know how it goes.
Thanks!

  • This reply was modified 10 years by Andrei L..
Post count: 16

Thanks. That works, I believe the itemprop in the a tag was causing issues for me earlier.

Viewing 5 posts - 1 through 5 (of 5 total)
The forum ‘Newsmag’ is closed to new topics and replies.