Forum Replies Created

Viewing 15 replies - 1 through 15 (of 7,440 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Thanks for the kind review!

    Plugin Author Hector Cabrera

    (@hcabrera)

    Alright, I’ll leave this topic as unresolved for the time being. Next time it happens try following the troubleshooting guide to find out what’s causing it and share your findings here.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @narolles,

    Looks like the plugin is not currently active on your site, and since you didn’t say what the error says I can’t tell what the problem is.

    Please let me know once the plugin is enabled again and I’ll have a look (or at least share the actual error message.)

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @samuelhadsall,

    Currently there’s only REST API endpoints, no GraphQL stuff yet. Since WPGraphQL became canonical though I plan to have a look and see if/how WPP could use it.

    Plugin Author Hector Cabrera

    (@hcabrera)

    It’s not that complex, really. Just download the latest zip file from here, then follow the manual installation process and you’re good to go.

    After leaving my original reply though I was thinking it might be best to just add that feature to the plugin itself to save people some time. For the time being though it has to be manually installed.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @alexmark001,

    Thanks for the suggestion, I really appreciate it (and thanks for the kind words, glad you like the plugin!)

    With that being said: Can I have an RSS feed of popular posts, please? ?? (I do note that I should probably add a link to that on the Description page of the plugin for more visibility so thanks for the reminder.)

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @ahneale,

    I noticed that before I turned off Data Caching, the table wp_popularpoststransients in the database was quite large (there were 100k+ records created over the 3 months from when WPP was first installed).

    That’s strange. Data Caching is enabled on my site and expires after 1 minute just like on your site (this is the default setting) and right now I have around 2000k entries on that table, all of them with a tkey_date no older than the last 24 hours. If I understood correctly, you’re seeing entries that are 3 months old on that table?

    In any case, it’s been a while since I last had a look at that part of the code. Seeing that my own transients table isn’t as large as yours I believe that yes there’s a system in place to prune it every now and then. I’ll have another look to jog my memory and see if there’s anything that could explain what’s going on on your end.

    For the time being, yes, please disable Data Caching.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hi @adesane,

    It seems that there’s a conflict with one of your other plugins. WPP’s script has been altered on your site (I guess that by some kind of site optimization plugin), this is what I’m seeing now:

    <link rel="preload" as="script" >

    And this is what it should look like instead:

    <script type="text/javascript" id="wpp-js" src="https://adesane.com/wp-content/plugins/wordpress-popular-posts/assets/js/wpp.js?ver=7.1.0" data-sampling="0" data-sampling-rate="100" data-api-url="https://staging.cabrerahector.com/wp-json/wordpress-popular-posts" data-post-id="0" data-token="f6b19dcc15" data-lang="0" data-debug="1"></script>

    That’s why the plugin isn’t currently tracking views by visitors.

    You’ll need to exclude WPP’s script from whatever you’re using to “optimize” your site, see Is WordPress Popular Posts compatible with plugins that minify/bundle JavaScript code? for more details.

    If you have any further questions please let me know.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hola @guillermo77,

    Desinstala el plugin y listo, con eso es suficiente. No necesitas hacer nada adicional.

    Plugin Author Hector Cabrera

    (@hcabrera)

    I did understand. Perhaps my previous comment could have been clearer.

    What I meant to say is that the only way to change anything from the stock HTML output is to modify it via post_html or using the filter hooks provided by the plugin, see How can I use my own HTML markup with WordPress Popular Posts for more details.

    I can remove it in the output file, but I’m afraid of updating later.

    I don’t recommend this for exactly that reason, changing plugin files is generally not a good idea since future updates will undo your changes. Follow the recommended way as described above and you should be good to go.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @quangtuyen1601,

    To customize the HTML output of your popular posts list, either to add or remove something, you can use either the post_html parameter in conjunction with the available Custom Tags to get the desired output.

    For example:

    [wpp post_html='<li>{thumb} {title} <div class="wpp-stats">Viewed {views} times, published on {date}</div><div class="wpp-taxonomy-wrapper">{taxonomy}</div></li>']
    Plugin Author Hector Cabrera

    (@hcabrera)

    At this point I’m willing to hire someone to help solve this. I’m at my wits end.

    Oh, I know that feeling haha. If it’s nothing urgent maybe taking a break from it for a little while might help (eg. work on something else or just take a break from the project). It’s very easy to burn yourself out when you can’t seem to find the solution to something right away, especially when it’s something that feels like should be trivial to fix.

    If it’s urgent though then yeah, getting another set of eyeballs on the problem may be the better choice.

    Plugin Author Hector Cabrera

    (@hcabrera)

    LCP issues due to a block of text is indeed strange (this is off-topic but I’ll allow it for a bit haha). Is that text being loaded via AJAX or something like that? Because otherwise I don’t see how it would cause LCP issues. Well, maybe if you’re loading a whole bunch of font files (font files for specific font weights, font files for different font faces, etc.) and the browser is just taking long to load them all?

    Plugin Author Hector Cabrera

    (@hcabrera)

    The file itself is around 5 Kb in size (when gzip compression is enabled), that’s not what’s causing the browser to take 450ms to load. It’s the REST API request it makes that may take time to return a response.

    In plain terms, it’s the time it takes for your server to return a response to the script what makes it seem like the browser is needing 450ms (in your case) to process wpp.min.js.

    Can it be deferred? Yes, however I don’t recommend it unless you don’t care about iOS / macOS visitors. In that case you could use the wp_script_attributes filter hook to programmatically add the defer attribute to the script (here’s an example that may help get you on the right track.)

    I would take a different approach: make sure that the REST API on your site responds as quickly as possible by improving anything server side that could be improved, including but not limited to: slow database queries, database optimization, object caching (usually not available on shared hosting plans), reviewing plugins / scripts to make your site as lean a possible by getting rid of code that’s no longer used / necessary, etc.

    Plugin Author Hector Cabrera

    (@hcabrera)

    Hey @quangtuyen1601,

    The post_html parameter expects an static HTML structure. It can’t do dynamic code like that, that’s why it’s not “working.”

    If you want to render dynamic content like your [count_chap] shortcode then do this instead:

    #1 Register a custom Content Tag called {render_count_chap} that will handle the output of your shortcode, like this for example:

    /**
    * Parses custom content tags in WordPress Popular Posts.
    *
    * @param string $html The HTML markup from the plugin.
    * @param integer $post_id The post/page ID.
    * @return string
    */
    function wpp_parse_tags_in_popular_posts($html, $post_id) {

    // Replace custom content tag {render_count_chap} with [count_chap]
    if ( false !== strpos($html, '{render_count_chap}') ) {
    // Get tags
    $count_chap = do_shortcode('[count_chap post_id="' . $post_id . '"]');
    // Replace {render_count_chap} with the output of [count_chap]
    $html = str_replace('{render_count_chap}', $count_chap, $html);
    }

    return $html;

    }
    add_filter('wpp_parse_custom_content_tags', 'wpp_parse_tags_in_popular_posts', 10, 2);

    This would go in your theme’s functions.php file.

    #2 Update your code so it uses the newly registered {render_count_chap} Content Tag:

    function truyen_hot_shortcode($atts) {
    // L?y tham s? num t? shortcode, m?c ??nh là 5
    $atts = shortcode_atts(array(
    'num' => 5,
    ), $atts, 'truyen_hot');

    // B?t ??u xay d?ng output HTML
    ob_start();

    if (function_exists('wpp_get_mostpopular')) {
    // G?i wpp_get_mostpopular() và s? d?ng post_html ?? ??nh d?ng HTML cho t?ng bài vi?t
    wpp_get_mostpopular(array(
    'limit' => intval($atts['num']),
    'range' => 'all',
    'order_by' => 'views',
    'post_type' => 'post',
    'stats_views' => 1,
    'thumbnail_width' => 158,
    'thumbnail_height' => 258,
    'wpp_start' => '<div uk-slider="autoplay: 1; autoplayInterval: 3000;" class="uk-margin uk-text-center uk-slider uk-slider-container" role="region" aria-roledescription="carousel"><div class="uk-position-relative"><ul class="uk-slider-items uk-grid uk-grid-small uk-grid-match" aria-live="off" role="presentation">',
    'wpp_end' => '</ul></div></div>',
    'post_html' => '
    <li class="uk-active" aria-hidden="false">
    <div class="el-item uk-grid-item-match">
    <a class="uk-cover-container uk-transition-toggle uk-display-block uk-link-toggle" href="{url}">
    <img src="{thumb_url}" width="158" height="258" class="el-image uk-transition-scale-up uk-transition-opaque uk-object-cover" uk-cover="">
    <div class="uk-position-bottom-center uk-overlay-primary">
    <div class="uk-overlay uk-padding-remove uk-margin-remove-first-child">
    <h3 class="el-title uk-h5 uk-margin-top uk-margin-remove-bottom">{text_title}</h3>
    <div class="el-meta uk-text-emphasis">
    {render_count_chap}, {views} l??t xem
    </div>
    </div>
    </div>
    </a>
    </div>
    </li>',
    'default_thumbnail' => get_stylesheet_directory_uri() . '/images/Chua-co-anh-bia.png', // ?nh m?c ??nh n?u kh?ng có thumbnail
    ));
    } else {
    echo "<!-- Plugin WordPress Popular Posts kh?ng ho?t ??ng -->";
    }

    return ob_get_clean();
    }

    add_shortcode('truyen_hot', 'truyen_hot_shortcode');

    That should do the trick.

    One observation though: that default_thumbnail parameter you have in your code is not doing anything. The wpp_get_mostpopular() function will ignore it as it doesn’t exist. See Parameters to see a full list of parameters accepted by the wpp_get_mostpopular() function.

    If you want to set a fallback thumbnail for when posts don’t have one then go to Settings > WordPress Popular Posts > Tools, under Thumbnails you’ll find an option to set the default thumbnail.

Viewing 15 replies - 1 through 15 (of 7,440 total)