“My Favorites” in Bricks

This Pro tutorial provides the steps to set up and use My Favorites in Bricks Builder.

Step 1

Install and activate My Favorites plugin. There are no settings to be configured for this plugin.

Step 2

To add the favorite heart button, edit your Template with Bricks and add this shortcode via a Shortcode element:

[ccc_my_favorite_select_button]

That will output an empty heart icon that gets filled when the user clicks on it to indicate that it has been added to the user's favorites.

Step 3

If you have a profile page in your site for each logged-in user and wish to show a link to the favorites page – /favorites (to be created in the next step), add this shortcode:

[ccc_my_favorite_list_menu]
A filled heart with the number of user's favorites will be shown

Step 4

Create a Page called Favorites.

We are going to cover 2 ways in which the logged-in user's favorites can be shown.

  1. Plugin shortcode
  2. Query Loop

Plugin shortcode

Advantage:

  • Favorited items can be unfavorited using the - icon. The plugin uses AJAX to remove any unfavorited item from the DOM.

Disadvantage:

  • Not possible/easy to modify the HTML output.

Edit Favorites Page with Bricks and add this shortcode:

[ccc_my_favorite_list_results]

At Bricks → Settings → Custom code → Custom CSS, add

.post-ccc_favorite .title-post {
	font-size: 1.2em;
	margin-top: 0.5em;
}

which results in, for example:

Query Loop

Advantage:

  • Total control of the HTML output. We can decide what data should be shown for each post.

Disadvantage:

  • There will be no AJAX way to delete the unfavorited item. The heart icon will toggle between unfilled and filled states when any item is unfavorited/favorited and the item (like post/page) will remain on the page.

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 524 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
Nested Queries in Bricks – Posts Grouped by Published Years and Categories

Nested Queries in Bricks – Posts Grouped by Published Years and Categories

In the past we showed how posts could be grouped by years in Bricks. This Pro tutorial takes it further by grouping posts by categories…
Categories:
Load more for Query loops in Bricks

Load more for Query loops in Bricks

Did you know that Bricks has AJAX loading for query loop posts on-click out of the box?
Categories:
Pro
Query Loop in Bricks

Query Loop in Bricks

This Pro tutorial walks you through the steps to use the Query Loop feature in Bricks to display a responsive grid of posts using CSS…
Categories:
Pro
Post-specific ACF Repeater Galleries as Sliders in Bricks

Post-specific ACF Repeater Galleries as Sliders in Bricks

How to output ACF Repeater field rows with the images of the Gallery-type sub field as a slider.
Pro
Dynamic Horizontal Posts Accordion in Bricks

Dynamic Horizontal Posts Accordion in Bricks

Update on 8 Sep 2024: You may want to follow the newer version that considers accessibility. Looking to make a Horizontal Image Accordion dynamic? This…
Pro
Dynamic Posts Lightbox in Bricks using GLightbox

Dynamic Posts Lightbox in Bricks using GLightbox

Steps to set create a dynamic lightbox with content from the post inside of the query loop.
Categories:
Pro
Events grouped by months within years based on event date custom field value

Events grouped by months within years based on event date custom field value

How to output events grouped by years and months using three nested query loops in Bricks.
Categories:
Pro
Posts Grouped by Post Dates in Bricks

Posts Grouped by Post Dates in Bricks

Setting up query loops for “Post Dates” with an the inner loop displaying all posts published on that day.
Categories: