How to edit post author/date area

Posted in: Newspaper
Post count: 12

Hello,

I have just bought the theme and may have a number of questions!

I would like to add an additional element to the line where the author and date is on posts. I know I will have to do this in the CSS files, but I do not know where to look.

I’m specifically looking to add a clickable Twitter follow button inline after the author. I already know this can be done as I did this manually on my previous theme using code as follows:

<?php if( $twitter_url = get_the_author_meta(‘twitter’) ) : ?>
” class=”twitter-follow-button” data-show-count=”false” data-show-screen-name=”false”>Follow @<?php echo basename($twitter_url); ?>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?’http’:’https’;if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+’://platform.twitter.com/widgets.js’;fjs.parentNode.insertBefore(js,fjs);}}(document, ‘script’, ‘twitter-wjs’);</script>
<?php endif; ?>

Post count: 6535

HI

This task cannot be achieve just by coping and pasting some code in a file. This may probably worked in a previous theme but we use a custom structure for files and it’s a bit more complicated.

You have to edit the file which correspond with thew post template used and paste the code in post’s meta-info container: http://screencast.com/t/ueEY2sfq You will also need some css customizations for button’s style otherwise the layout may affected a bit.
To achieve this task you need some basic codding skill as there are required changes in theme’s code. Unfortunately we can’t offer customization services at the moment so if you still need guidance on this or you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you. Also consider using theme sharing buttons which include twitter, as an alternative: http://screencast.com/t/CSlSFryt

Thanks!

Post count: 12

Hello,

Thank you for your first reply. Unfortunately, it has only half answered my question.

I have went through the theme files that you have highlighted and added code. This works on the themes in which the td-module-meta-info is in the loop file (e.g. loop-single-1, loop-single-5).

But, for those where the meta information is in the single template files instead (e.g. single_template_3, single_template_6), it has no effect. The code is stripped by the theme. If I add plain text in the same spot, it will display, but the code acts as if it was never added.

This is the section after additional code:

<div class="td-module-meta-info">
<?php echo $td_mod_single->get_author();?>   <?php if ( get_the_author_meta( 'twitter' ) ) : ?>
" class="twitter-follow-button" data-show-count="false">Follow @<?php the_author_meta( 'twitter', $author_id );?><script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
<?php endif; ?>
<?php echo $td_mod_single->get_date(false);?>
<?php echo $td_mod_single->get_comments();?>
<?php echo $td_mod_single->get_views();?>

Given this code does not seem to impact the website, I am not sure that it is in fact correctly added in this location for these templates. Is there an additional file for the meta information of that section for those layouts?

Please note that I am not asking for customisation and while I may not be a developer, I am clearly competent enough to have got this far. However, I cannot see which other files would be correct to add code for templates 2, 3, 4, 6, 7, 8, 11, 12 and 13.

The theme sharing buttons are not the same thing as they are to share a post, not to follow the author with the Twitter button.

I hope as a new customer that you will be able to provide a further pointer. 🙂

Post count: 6535

HI

Each post template is generated from two files single-teplate-x.phph + loop-template-x.php and depending by post template each file generate a specific part. The code that you’re using does not seems to be correct, there are some html errors and also $author_id is not a valid parameter for the_author_meta() function.
For more details about how can you use this function please check wp’s documentation: https://codex.wordpress.org/Function_Reference/the_author_meta

Thanks!

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