kylephillips / favorites

Simple and flexible favorite buttons for any WordPress post type.
https://favoriteposts.com
224 stars 85 forks source link

Favorite button quickly flashes in the favorite list for each list item #71

Open speir-wang opened 7 years ago

speir-wang commented 7 years ago

Hey there,

I enjoy working with this plugin very much, but I am currently having an issue about showing the user favorite list.

I've tried 1) using the shortcode [user_favorites]; 2) function call get_user_favorites_list(); 3) another function call the_user_favorites_list() to show a list of posts that favorited by a user, and all of these methods show a favorite button for each favorited post on initial page load, and hide the button after the page load is complete.

I thought it might have something to do with option include_buttons=false, but it doesn't have any effect on the flashing button.

Is there any way to avoid the favorite button flash on favorite list on initial page load?

Thanks in advance. He

gfargo commented 7 years ago

Hey @speir-wang,

You could try filtering the favorites list to remove the button html via one of the filters provided in the plugin? e.g. favorites/list/listing/html

/**
* Customize the Favorites Listing HTML
*/
add_filter( 'favorites/list/listing/html', 'custom_favorites_listing_html', 10, 4 );
function custom_favorites_listing_html($html, $markup_template, $post_id, $list_options) {
        // Filter out our button HTML from $html
    return $html;
}

If this doesn't work or you can't figure out how to string the button HTML, you could always use get_user_favorites() function to grab an array of favorite Post IDs and loop through each ID. This would give you complete control over the markup output.