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

    (@hcabrera)

    Hi there!

    Indeed, WPP only tracks the following post types: post, page, and CTPs. Other post types, such as attachment, are ignored by the plugin.

    If you want WPP to track attachments as well, you’ll have to make a change in the code:

    1. Go to Plugins > Editor and select WordPress Popular Posts from the dropdown.
    2. Find this line (as of version 3.2.2), and change it to:

      if ( is_singular() && !is_front_page() && !is_preview() && !is_trackback() && !is_feed() && !is_robots() ) {

    3. Hit the Update file button to save changes.

    Note that any changes made to plugin files will be lost the next time you upgrade it, so you should bookmark and / or save this topic somewhere for future reference.

    Thread Starter old9

    (@old9)

    Thanks for your reply!

    I tried this but still ‘No data so far.’ 🙁

    The views count does get saved since wpp_get_views() has valid return in my attachment.php template, and this is true even before I made the code change you suggested.

    BTW, I noticed that is_single, is_attachment and is_singular all return true on attachment.php, and I made some search and the codex page also indicates this: https://codex.ww.wp.xz.cn/Function_Reference/is_single#Notes.

    Plugin Author Hector Cabrera

    (@hcabrera)

    That makes sense. The attachment.php file is the single.php for media files. Never thought of that.

    Gimme a second, just got home and the laptop isn’t on yet. I’m sure I’m forgetting something.

    Edit: I was right, there’s an additional change to be made.

    Attachments are stored in the wp_posts table with status ‘inherit’. WPP retrieves only posts with status ‘publish’. The link above should take care of that.

    Thread Starter old9

    (@old9)

    Thanks, this works.
    Any chance this would be merged into the main branch?

    Plugin Author Hector Cabrera

    (@hcabrera)

    I may consider it. I need to know first if this change has any other side effect I may not know about (eg. under what other conditions is the ‘inherit’ status used).

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Does not work for media files’ is closed to new replies.