Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

 

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
New Webmasters ask "How-To" questions here. This is where other fucking Webmasters help.

 
Thread Tools
Old 10-10-2015, 05:05 AM   #1
EN1GMA
Confirmed User
 
EN1GMA's Avatar
 
Industry Role:
Join Date: Nov 2005
Posts: 1,243
How to display wordpress popular posts by views of each category?

Hello guys,

Can someone help me with this code?
I want to display most popular posts by views of each category...
I already have a code working but only shows the popular posts of all, not for each category...

Here is my code in single.php file:

PHP Code:
<?php
foreach(get_the_category(get_the_ID()) as $keys){
    
$cu $keys->cat_name;
}
?>
<h2 class="single-post-external" style="background: #9F0C67; padding: 8px 0 8px 8px;">Most Viewed Posts in <?php echo $cu?> Category<?php //echo  "Like ".get_the_title(); ?></h2>    
    <?php setPostViews(get_the_ID()); ?>
    <?php query_posts('posts_per_page=8&meta_key=post_views_count&orderby=meta_value_num&order=DESC'); ?>
    <div id="main_container" class="mrCatouter container  clearfix">
    <?php while ( have_posts() ) : the_post(); ?>
And in my functions.php file I have this:
PHP Code:
function setPostViews($postID) {    
    
$count_key 'post_views_count';    
    
$count get_post_meta($postID$count_keytrue);    
    if(
$count==''){        
        
$count 0;        
        
delete_post_meta($postID$count_key);        
        
add_post_meta($postID$count_key'0');    
    }else{        
        
$count++;        
        
update_post_meta($postID$count_key$count);    
    }

I think that I need to change:
Code:
query_posts('posts_per_page=8&meta_key=post_views_count&orderby=meta_value_num&order=DESC');
but I don't have sure what to do...

Hope to see some help here

Thank you guys!

Kind regards,
EN1GMA


----------------------
EDIT
----------------------
I found out that adding a &cat= after DESC and enter the id number for the category it works
But I dont want to show a specific category, I want to show the category where the post is in...
Any ideas?
EN1GMA is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 10-11-2015, 08:52 AM   #2
baggg
So Fucking Banned
 
Industry Role:
Join Date: Mar 2012
Location: EEA
Posts: 1,432
Check for plugins
baggg is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 10-11-2015, 01:23 PM   #3
Denny
Too lazy to set a custom title
 
Denny's Avatar
 
Industry Role:
Join Date: Feb 2005
Posts: 17,074
Quote:
Originally Posted by baggg View Post
Check for plugins
Yep
__________________
Denny is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 10-11-2015, 03:14 PM   #4
topadult
Confirmed User
 
Industry Role:
Join Date: Jun 2015
Posts: 507
Hi EN1GMA,
I suggest you use Wordpress plugin "WordPress Popular Posts".
If you have any question, do not hesitate to post here or email me, I will help you.
Regards.
__________________
Looking for adult SEO service that works? Click here for more infos ;)

Email: pro.topadult at gmail dot com
Skype: protopadult
ICQ: 690852277 (rarely use)
topadult is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 10-14-2015, 07:21 PM   #5
tonyantone
Confirmed User
 
tonyantone's Avatar
 
Industry Role:
Join Date: Apr 2012
Posts: 284
Thanks for this information I was not aware of this Plugin,
I will give a try. Plugins are the way to go on Wordpress for sure, I use
quite a few of them it really makes life easier! Thanks again for post!






TraffDAQ - Multiply Your Adult Traffc!



TraffDAQ

is an awesome one-of-a-kind, automated
traffic exchange network for adult webmasters.
Turn Random Clicks on Your Site into Brand New Visitors FREE!


tonyantone is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
 
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks

Tags
category, posts, $count_key, code, popular, file, views, guys, display, $count, en1gma, hope, edit, enter, specific, post, ideas, adding, &cat=, desc, found, post_views_count;, viewed, single.php, wordpress



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.