• Resolved rrjmdpa

    (@rrjmdpa)


    On the WPP admin stats screen, it lists the top posts by volume and their title.

    Is there any way to modify that listing to include other post parameters? Such as: we might want to also see the date published and/or category or such so that we can tell if we’re getting better or worse etc.

    Also, as in my case, disliking ads so much I don’t want to enable them except for where they’ll do the most good and won’t interfere with the message. I do that through a custom field (has_ad) and would like to know if, for example the top ten posts “has_ad”.

    There is so much empty space on the standard admin listing that a couple extra columns could easily fit. Is there an action hook or something that we could program an extra field or two? Or where is the template for that list that we might modify it?

    Thanks

    https://wordpress.org/plugins/wordpress-popular-posts/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    Is there any way to modify that listing to include other post parameters? Such as: we might want to also see the date published and/or category or such so that we can tell if we’re getting better or worse etc.

    Most of the stats section is hardcoded and can’t be heavily modified without hacking its code directly (which I personally don’t recommend).

    However, it is possible to customize the listings to add more info -such as the categories and publish dates- via wpp_post. You could also use the wpp_custom_html filter hook, but I believe the former works best in this case.

    You’d need to do something like this:

    function my_custom_admin_single_popular_post( $post_html, $p, $instance ) {
    
        // Change the HTML markup for the admin section only
        if ( is_admin() ) {
    
            /*
             *  Use the data contained in the $p post object
             *  to build your custom HTML (category, publish date, etc),
             *  and then return the HTML output.
             */
    
            return $output;
    
        }
    
        // Not in the admin section, let's return the original post HTML markup
        return $post_html;
    
    }
    
    add_filter( 'wpp_post', 'my_custom_admin_single_popular_post', 10, 3 );

    Also, as in my case, disliking ads so much I don’t want to enable them except for where they’ll do the most good and won’t interfere with the message. I do that through a custom field (has_ad) and would like to know if, for example the top ten posts “has_ad”.

    I didn’t understand this. Could you please elaborate a bit more?

    Thread Starter rrjmdpa

    (@rrjmdpa)

    Thanks for responding.

    Actually I was anticipating that you’d tell me it was hard coded and no “hooks” were available to alter the “stats list.” I spent quite a bit of time burrowing through the code and most of it I sort of understood but never found anything that I felt sure was the part which outputted the actual list.

    Google analytics gives us the top five posts right on the WordPress admin screen. But we need to navigate a couple of screens down into “settings” in order to see the “WP Popular posts” screen where it tells me the top 20 (that’s what I’ve got it set at).

    I don’t use WPPP for anything except that list so the code you mentioned above may not apply to me — I’m not even sure where the ‘my_custom_admin_single_popular_post’ that you mention would even be printed out.

    I would be interested in figuring out how to place a WPPP “top 10” listing right on the WP main admin screen (just like google analytics does) AND somehow modify the code which prints out the WPPP stat listing (under settings) to include:

    A) the posted date [because, if I click on the name as it now exists I’m directed to the actual post and NOT the post’s edit screen. In my case I have to first go to the post in order to find the date it was published, then go back to the wp posted list and scroll all over to find the date, then open the post to do any editing – very convoluted. Better if WPPP would tell me the date published when it told me the top 20 or even had an “edit post” link like it does “view post”.]

    and B) the value of a custom field that I’ve created, via the Advanced Custom Fields plugin, called “has_ad”. I use that field as a Boolean value which I’ve programmed to print an “ad by google” on the page if the value is set to true. That way I can toggle the value on and off in order to display an ad only on select pages. I just thought that if I could have WPPP display 0 or 1 (the contents of that custom field) on the settings top 20 list it would save me a lot of convoluted extra work. I realize it’s a bit custom to my situation but the concept of allowing users to select extra data to display wouldn’t be.

    There is so much unused space on the listing that it could readily accept some more data. If I just knew for sure where the code that printed that list was perhaps I could fool around enough to add a bit of extra info. If you could tell me that, it would help.

    I have to say that Yoast and all the other yahoo’s seem to take control of some widgets on the WP admin display – perhaps WPPP would benefit from a list there too that we could turn on if we wanted.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Both changes (adding the publish date and the value of your custom field to each post under the Stats section) can be done via the wpp_post filter hook. Give the documentation a look, and if you get stuck somewhere along the way please don’t hesitate to ask.

    About the idea of adding a Stats widget a la Google Analytics to the Dashboard, I’ll think about it.

    Thanks for the suggestions!

    Thread Starter rrjmdpa

    (@rrjmdpa)

    Thanks… I’ll take another look at the doc. I couldn’t tell that the wpp_post filter was a hook to the listing on the stat’s page as well as for listings in the single page and shortcode – which, I think, is what you’re saying. And I guess the doc will tell me that I need to obtain the values and wrap them inside some < li > code or something as well. Will post back when (I’m sure I will) I have questions.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘WPP admin screen modification’ is closed to new replies.