Using a function to change favorites listing

Sorry - total newbie here with Wordpress development.

I have the following plugin installed https://favoriteposts.com/ and it allows you to change the default output of the users favorites by using the following function:

/**
* 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)
{
    return $html;
}

I just don't know how to use this.

What I would like is for the output to match that of the default woocommerce product loop. The only custom post type I've selected in the settings for this plugin is 'product'.

Any advice?

Topic functions plugins Wordpress

Category Web


I recently needed to change the default output also. Here's how I used this filter to add the post content to the output.

/**
* 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) { 
    $html = '
    <li class="favorite">
        <div class="favorite-image">
            ' . get_the_post_thumbnail( $post_id, 'our-products' ) . '
        </div>
        <div class="favorite-wrapper">
            <h2 class="favorite-title">
                ' . get_the_title($post_id) . '
            </h2>
            <div class="favorite-content">
                ' . get_post_field('post_content', $post_id) . '
            </div>
            <a class="btn green-arrow" href="' . get_the_permalink($post_id) . '">View Recipe</a>
        </div>
    </li>
    ';

    return $html;
}

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.