• Resolved NAROLLES

    (@narolles)


    Hi
    after the update plugin
    I observe another anomaly it seems to me ….

    The following script allows to display on the front side only posts less than one year old in display blocks (list)
    it has been used for 2 years and I believe it comes from an exchange between us.
    Now
    When the script is active ….. the “get views” counters of posts older than one year go to zero
    when it is inactive … the “views” counters return to the correct position
    I therefore leave inactive for the moment while waiting for the solution.

    //////////////////////////////////////////////////////////////////////////////
    WPP 2019 LIMITE ARTICLE DE MOINS D UN AN
    Filters out popular posts that are older than the
    specified time.
    @ param string $where
    @ param array $options
    @ return string

    function wpp_filter_posts_by_age($where, $options){
    if ( ! is_admin() ) {
    $where .= ‘ AND p.post_date >= DATE_SUB(NOW(), INTERVAL 1 YEAR) ‘;
    }

    return $where;
    }
    add_filter(‘wpp_query_where’, ‘wpp_filter_posts_by_age’, 10, 2);

    //////////////////////////////////////////////////////////////////////////////////////

    • This topic was modified 3 years, 7 months ago by NAROLLES.
    • This topic was modified 3 years, 7 months ago by NAROLLES.
    • This topic was modified 3 years, 7 months ago by NAROLLES.
    • This topic was modified 3 years, 7 months ago by NAROLLES.
    • This topic was modified 3 years, 7 months ago by NAROLLES.

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

Viewing 5 replies - 1 through 5 (of 5 total)
  • I also had this same error after updating the plugin version.

    to fix it I edited the file below:
    /wp-content/plugins/wordpress-popular-posts/src/template-tags.php

    and I changed the search parameters of the query getting as shown below.

    before:

    $args = [
            'range' => 'all',
            '_postID' => $id
        ];

    later:

    $args = [
            'range' => 'all',
            '_postID' => $id,
            'post_type' => get_post_type($id)
        ];
    Thread Starter NAROLLES

    (@narolles)

    Merci @guilherme77

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, I managed to reproduce the bug so thanks for the detailed report @narolles.

    Below you’ll find an updated version of the wpp_get_views() function that should fix the issue. Please follow the instructions as detailed below to test it (and please be extra careful as you’ll be editing code on a live website):

    1. Go to WP Dashboard > Plugins > Plugins Editor.
    2. Use the dropdown at the right to select the WordPress Popular Posts plugin.
    3. Click on src > template-tags.php to edit this file.
    4. Replace the contents of the file with this version.
    5. Scroll down and click on Update file to save changes.

    Please report back your results.

    Thread Starter NAROLLES

    (@narolles)

    thank you so much @hcabrera
    I followed your directions and it works.

    I allow myself a suggestion, given the quality of your work.
    why not make a special elementor or divi widget or plugin … even in premium I think there is an interest

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @narolles,

    Thanks for reporting back. Glad to know that the patch worked! I’ll push a new update soon so thanks for all the feedback, I really appreciate it.

    About your suggestion, I’ll think about it. A pro version of the plugin with special widgets & functions doesn’t sound so bad. Will look into this once I get some spare time.

    Have a nice day!

    • This reply was modified 3 years, 7 months ago by Hector Cabrera. Reason: Fixed typo
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘CONFLICT COUNTER VIEWS / SCRIPT OLDER POST’ is closed to new replies.