Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Help Adding Custom Tab for "Most Read" To Juggernaut WP Theme WordPress

  • SOLVED

Basically I have the Juggernaut WP Theme, and it has a tabbed post display. I want to add a new tab, for "Most Read" posts to be displayed, which will show articles ranked by highest view count in descending order.

Answers (2)

2012-01-19

idt answers:

Hi,

I think you can do it using the following steps:

1. You need to install WP-Postviews.1.50 plugin. Set settings depending on your needs. WP-Postviews is needed because Wordpress by default does not count numbers of views.

2. On your index.php, just below:
<!--End Most Comments Tab-->

Add this block of code:
<!--Most Read Tab-->
<div class="panel" title="Most Read">
<?php
$args = array(
'cat' => $theme_exclude_homepage_posts,
'posts_per_page' => $theme_number_of_posts,
'more' => $more = 0,
'meta_key' => 'views',
'orderby' => 'meta_value_num',
'order' => 'DESC',
); ?>
<?php query_posts($args); while (have_posts()) : the_post(); ?>

<?php require('post-loop.php'); ?>

<?php endwhile; wp_reset_query(); ?>

</div>
<!--End Most Read Tab-->


Hope that helps.

Thanks,
idt


Teny comments:

Hello, I tried this and it seems to work properly. The only issue is that regardless of setting config I cannot seem to get the number of views to display.

I believe this may be the issue, do you know how to resolve it?



"These options specify where the view counts should be displayed and to whom. By default view counts will be displayed to all visitors. Note that the theme files must contain a call to the_views() in order for any view count to be displayed."


idt comments:

On your post-loop.php, before &nbsp;&nbsp;&nbsp;
add this &nbsp;|&nbsp;<?php the_views(); ?>

That should display number of views per post.


Teny comments:

Hello, I have done what you've suggested and the code looks as follows:

{ ?><?php

comments_popup_link(gp_no_comments, gp_one_comment, gp_more_comments, 'comments-link', ''); ?><?php } ?

>&nbsp;|&nbsp;<?php the_views(); ?>&nbsp;&nbsp;&nbsp;<?php edit_post_link('(Edit)', '', ''); ?></div>


Do you think I've inserted it correctly?

The views appear on the front page, while the posts are displayed on tabbed view, but if I click on the article, or for example browse the category the article belongs to, I do not see any views there.

I have it set to display post views everywhere on the site, is there a way to fix this?


idt comments:

Yes. That seems correct.

The theme you are using used custom queries so you have to manually place that code to places where you want it displayed. Though, I believe the post-loop.php template modification will cover most of the places. Just try it out.

Thanks,
idt


Teny comments:

I'm not too sure what you mean, could you help me have it displayed in the categories? Also I'm not sure if you noticed this, but when you click the tab, it changes the sites url to site.com/#1 or something.

Is there a way to change that, it's very annoying ):


idt comments:

Just try the post-loop.php changes I've told you. If a post has views, it should should be displayed when you click on categories.

No easy way to do that. It needed modification with the jQuery plugin the theme is using.


Teny comments:

Ah, I'm not really sure what you mean by additional modifications to post-loop, I've only made the change you mentioned above to make a reference to post_views();

Thank you very much for the help though =)

2012-01-19

Buzu B answers:

Well, this sounds rather easy, but I never worked with that theme before. Would it be OK if I solve the issue for you? I would need access to the server where the files are hosted, or if they are in a local host, we could work over teamviewer. Since this discussion, should you accept my proposal, would have nothing to do with the question asked, but rather with exchange of personal information, I suggest you contact me directly by sending a private message here on wpquestions.


Teny comments:

I cannot give you access to the server files 'directly' because they are hosted on a dedicated server for which even I only have limited access. TeamViewer works fine for me if you believe you have a solution that would work for this, get in touch with me asap.