WordPress Top 10 Plugin: Place Counter in Byline

This content 8 years old. Please, read this page keeping its age in mind along with the fact technology changes fast and the information on this page me be outdated, not best practice, or plain wrong.

I was annoyed by how the Top 10 plugin didn’t give me a better control of placement of the Visits/Visited string, so I got to work figuring out where to move things around.

First, I found that the data is printed via a PHP function called echo_tptn_post_count()

I edited my child-theme’s content.php file and modified the following (bold):

<?php if ( is_singular() ) { ?>
<?php if(function_exists('echo_tptn_post_count')) { $foo=echo_tptn_post_count(); } ?>
		<?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
		<?php echo apply_atomic_shortcode( 'byline', '<div class="byline">' . __( 'Published by [entry-author] on [entry-published]  [entry-comments-link before=" | "] '.$foo.' [entry-edit-link before=" | "]', 'live-wire' ) . '</div>'); ?>

When I viewed the post, I saw it was screwing up and echo’ing the $tptn variable above my entry title!

I went and had a look at the echo_tp_tn_post_count() function in top-10.php in the wp-content/plugins/top-10 directory and changed the following (bold):

function echo_tptn_post_count() {
global $post,$tptn_url,$tptn_path;
$id = intval($post->ID);

$output = '<script type=text/javascript src='.$tptn_url.'/top-10-counter.js.php?top_ten_id='.$id.'></script>';
#echo $output; return $output;

Now, it prints right in the byline after the comments (and it only does this on posts…).


This probably wasn’t the RIGHT way to do it, but I figured it out.

Speak Your Mind


This site uses Akismet to reduce spam. Learn how your comment data is processed.