• Hello
    I used your code.
    “get_user_favorites_count($user_id = null, $site_id = null, $filters = null);”
    it works well.
    By the way, it doesn’t show result immediately like “echo get_favorites_button($post_id, $site_id)”
    I have to input f5 to refresh or go other page.
    Is there a way to get immediate total count??

    https://www.ads-software.com/plugins/favorites/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, I used the Ajaxize Plugin along with the Favorites plugin to achieve this: https://www.ads-software.com/support/plugin/ajaxize

    Install the plugin and generate a div from get_user_favorites_count, use this in your template instead of the function. Then I altered a JS Snippet I found on their FAQ page to refresh the value after you click the “add to favorites” Button.

    <script>
    jQuery(document).ready(function($) {
        var refreshId = $( ".simplefavorite-button" ).mouseup(function() {
    
            var $data = $('div[id*="ajaxize_this:REPLACE_THIS"]');
            $data.each( function() {
                $data.fadeTo(500, 0, function() {
                    var newquery = $.query.set('ajaxize_this', $data.attr('id')).set('_wpnonce', ajaxizeParams._wpnonce);
                    $data.load(location.pathname + newquery, function() {
                        $data.fadeTo(500, 1);
                    });
                });
            });
    
            return false;
        });
    });
    </script>

    Hope this helps!

    Hi swagzillionaire,

    Thanks so much for your instructions!

    Could you describe your steps just a little bit further? I’m still a WP newbie, and am not sure how to do what you describe.

    Here’s what I did so far:
    1. I installed the Ajaxize plugin.
    2. In the Dashboard, I went to ‘Settings’ -> ‘Ajaxize’. Then in the ‘Function Name’ box, I typed: get_user_favorites_count, and clicked ‘Generate Div’.

    Now, I’m not sure what to do next.

    How do I ‘use this in your template instead of the function’, as you say?

    How do I add the JS script that you have included here?

    Thank you in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Immediately Changing total favorite count for a user’ is closed to new replies.