Plugin Author
Ajay
(@ajay)
@sumon1068
Happy to include this. Where exactly are you modifying the plugin. And, if you are on Github, it might be easier to send a PR?
I am modifying popular-authors.php file, the modules section.
And sorry, I don’t use Github.
Thank you for considering.
Plugin Author
Ajay
(@ajay)
Plugin Author
Ajay
(@ajay)
@sumon1068
I wanted to update you that I have implemented a custom template feature. Note that it doesn’t work as you’ve done above but a relatively cleaner approach.
Sample code below on how to override using the new filter. You can use from the main.php you created.
function override_wzpa_custom_template( $template, $authors, $args, $post_counts ) {
$output = '';
foreach ( $authors as $author ) {
$author_id = $author->author_id;
$views = $author->visits;
$no_of_posts = isset( $post_counts[ $author_id ] ) ? $post_counts[ $author_id ] : 0;
$output .= "HTML for the template: $author_id | $views | $no_of_posts \n";
}
return $output;
}
add_filter( 'wzpa_custom_template', 'override_wzpa_custom_template', 99, 4 );
@ajay
Happy to see the custom template feature you’ve added. It’s working fine for me.
But there has another problem risen. Remember this thread?
It’s including custom post type counts again. As previously I was using edited main.php, I added this line:
$where .= " AND {$posts_table}.post_type = ‘post’ “;
Now there is no main.php and I don’t want to edit the plugin.
So, here is the dillema: I want counter enabled for custom post type (as I need to know which custom post type post is getting viewer’s attention), but I want to show popular authors based on Post views only, no custom post views added.
Please add a Popular Authors menu in the dashboard to let choose whether we want to add custom post type views or not.
Thank you.
Plugin Author
Ajay
(@ajay)
@sumon1068
I have this filed as a future feature in v1.3.0
https://github.com/WebberZone/popular-authors/issues/10
But, there are also a lot of filter functions added in this version, so until then you can do something like this in your theme’s functions.php to choose which custom post type you want.
function filter_wzpa_query_where( $where ) {
global $wpdb;
$posts_table = $wpdb->get_blog_prefix() . 'posts';
$where .= " AND {$posts_table}.post_type = 'post' ";
return $where;
}
add_filter( 'wzpa_query_where', 'filter_wzpa_query_where' );
Excellent! This works fine.
Thank you.