• Resolved Morshed Alam

    (@sumon1068)


    Hello,

    This is actually a feature request. I have been using your plugin by modifying it a little bit.

    Here’s what I am using:

    $original_template = plugin_dir_path(__FILE__) . "includes/main.php";
    $override_template = get_stylesheet_directory() . "/includes/main.php";
    if(file_exists($override_template)){include( $override_template );}
    else{include( $original_template );}
    //require_once POP_AUTHOR_PLUGIN_DIR . 'includes/main.php';

    I did this to customize the output. I don’t know what it is called. Maybe creating Custom Template or something. Many modern plugins are allowing this.

    So my request to you that please add above code to your plugin so that every time the plugin gets an update we won’t have to modify the file.

    Thank you.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • 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?

    Thread Starter Morshed Alam

    (@sumon1068)

    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)

    I’ve filed this in Github for implementation – https://github.com/WebberZone/popular-authors/issues/13

    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 );
    
    Thread Starter Morshed Alam

    (@sumon1068)

    @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' );
    Thread Starter Morshed Alam

    (@sumon1068)

    Excellent! This works fine.

    Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Feature Request’ is closed to new replies.