How to Add Favorite Button Functionality to Your Divi Site

Last Updated on September 12, 2022 by 12 Comments

How to Add Favorite Button Functionality to Your Divi Site
Blog / Divi Resources / How to Add Favorite Button Functionality to Your Divi Site
Play Button

Adding favorite button functionality to your Divi site can be a great boost to user experience. The basic functionality works as a bookmarking system for posts. Users can browse through posts and select the ones they want to favorite. Then users can view those favorited posts later at their convenience.

For this use case tutorial, I’m going to show you how to add favorite button functionality to Divi’s Animal Shelter Layout Pack. This will allow the user to select certain pets as their favorite and then view those pets on a separate β€œmy favorites” page.

Let’s get started.

Sneak Peek

Here is a peek at the favorite button we’ll be adding to our project posts.

favorite button

favorite button

Here is an peek at the favorites page we’ll be building to show user favorites.

favorite button

What You Need

For this use case tutorial, you will need the following:

The Plugin Settings

Once the plugin is installed, you can access the settings from the WordPress dashboard by navigating to Settings > Favorites.

Enable Favorites for Projects

Click on the Display & Post Types tab on the Favorites Settings page. Then select to enable Projects as the designated post type you want to grant favorite button functionality.

Note: You don’t have to set them as projects. You can enable posts or pages if you like. I thought it would be nice to use projects just in case I wanted to use the portfolio module to display my listings down the road.

Once checked, click the Settings button that appears to the right and update the following:

Include before content: uncheck
Include after content: uncheck
Add meta box: check
Add admin column: check

favorite button

We are not checking the option to include the button before or after content because we are using the Divi Builder. We will use a shortcode to display the button within a text module.

Customize the Favorite Button Content & Appearance

Next set the Button HTML Element to β€œa (link)”. This will allow us to design the link from within the text module later on.

Set the Button Type you want to use. I would suggest using the predefined buttons instead of a custom markup, unless you know what you are doing. I’m going to use the Favorite Button Type.

Specify the custom colors you want to use for the button. Update the following for the default button state:

Background Color: #ffffff
Border Color: #d29f68
Text color: #d29f68
Icon Color: #d29f68

For the active button state, update the following:

Background Color: #d29f68
Border Color: #d18d45
Text color: #ffffff
Icon Color: #ffffff

You can even preview what the button will look like in the Button Type section above (it’s clickable as well).

favorite button

Customize the Favorites Listing Display

Under Listings Display, select to customize the favorites list HTML and click the settings button to the right. The primary reason I decided to do this was that I found it difficult to get thumbnails to display with the favorites listing shortcode, so I decided to create a customized output for my listings.

By default the favorites list will be displayed in an unordered list with β€œul” as the list wrapper type and β€œli” as the list element type. However, I find it more difficult to style the default setup with Divi, so instead, set the List wrapper type to β€œDiv” and the List Element Type to β€œDiv”.

favorite button

Next, select to Customize the single Listing Content Markup. You will see a wysiwyg editor to customize what listing content you want to show when using the favorites listing shortcode. You can add dynamic fields by choosing them from the dropdown list and they will be added to the content editor box. Make sure you have the visual tab selected when added the dynamic fields (it may not work with the text tab selected).

favorite button

Under post fields, add the field β€œThumbnail:thumbnail”. This generate the following code in the editor:

[post_thumbnail_thumbnail]

favorite button

The will show the thumbnail (featured image) you have selected for the project post.

Next, add the field β€œPost Title” from the dropdown. This generates the following in the editor:

[post_title]

favorite button

This will show the post title of project post.

If you plan on giving your posts a custom excerpt, you can add the β€œPost Excerpt” field as well. This is a great way to provide some info about the favorited listing/pet that users can see in their favorited list.

The post excerpt field will be the following:

[post_excerpt]

favorite button

Now that we have our fields in place, we can wrap our thumbnail and post title in an β€œa” tag in order to turn it into a link that will redirect to the post permalink. Since we want the permalink to be pulled from the post, we need to add the custom field β€œPost Permalink” for the href value for each of our links. Here is what the final html should look like in the editor:

<a href="[post_permalink]">[post_thumbnail_thumbnail]</a>
<a href="post_permalink]">[post_title]</a>
<p style="margin-bottom: 30px;">[post_excerpt]</p>

Note: I wrapped the post excerpt field with a paragraph tag and added some bottom margin to create a little space between the listed items.

favorite button

Once done, save your settings.

Here is a sneak peak of what this output will look like whenever we use the shortcode to show user favorites.

favorite button

General and Users Settings

I’m keeping the default functionality of the favorites plugin under the General and Users tab. By default the plugin enables anonymous users (users not logged in) to have favoriting functionality by saving favorites as cookies. If you want to force users to login before favoriting, you can do this under the Users tab.

Adding Your Pet Listings as Projects

Now we are ready to start creating our project posts to serve as our individual pet listings. To add a new project, go to the WordPress dashboard and navigate to Projects > Add New.

Enter a title for your post (ie. the name of the pet), add a featured image, enter the content you want to display in the listing page in the excerpt box.

favorite button

Import the Listing Page Layout

Next we need to add our premade listing page layout from the Animal Shelter Layout Pack. To do this, first deploy the visual builder.

Open the settings menu and add the Animal Shelter Listing Page Layout to the post.

Insert Favorite Button Shortcode

You can add the favorite button anywhere on the page by using a shortcode. For this use case, let’s add it right under the photos in the left column in the first section.

Add a text module and enter the following shortcode in the content box:

[favorite_button]

favorite button

You can change the style of the button (it is technically a link) using the design settings if you want. Just be careful not to override the color you set in the plugin settings. For example, you can go to the design tab and click the link tab under the text category and update the following:

Link Font: Lora
Link Font Weight: Bold
Link Text Size: 16px

This is the most basic usage of the shortcode. There are a few additional parameters you can add to the shortcode to customize the functionality. You can check those out on the plugin page or their main website for more examples and shortcodes.

All that is left to do is update the content of the post as needed and you are done. Save settings.

Tip: You may want to save your text module with the favorite button shortcode as a global item in order to make it easier to add and edit the button on all listings.

Here is what the layout looks like with the favorite button:

favorite button

favorite button

Create a Page to List Favorites

Once a user clicks on a button to favorite a post, the post is saved (using cookies) and is able to be listed anywhere on your site using a shortcode. For this use case, I’m going to create a new page to list those posts that have been favorited.

Create a new page (Pages > Add New). Give the page a title (ie. β€œFavorites”). And deploy the visual builder.

Import the About page Layout

Next, add the Animal Shelter About Page layout to the page.

Update the Fullwidth Header Module settings at the top of the page to include a new title and subheading text. Then delete the button text for both buttons.

favorite button

Add User Favorites Shortcode

At this point, all you have to do is decide where you want to add the shortcode and which elements of the layout you want to keep (or rearrange) to design your page.

In the second section, the first row has two columns. Delete the text module in the second column and update the content of the text module in the first column with the following title and shortcode:

<h3>My Favorites</h3>
[user_favorites]

This user favorites shortcode will display all of the user’s favorites they have selected.

favorite button

Then go to the design settings to customize the text deployed by the shortcode however you want. For this example, I’m simply going to change the link text design in order to target the post title link deployed in the shortcode as follows:

Link Font: Lora
Link Font Weight: Bold
Link text Color: #d29f68
Link Text Size: 20px

favorite button

Now you can add additional elements to the right column if you want and delete the rest of the layout elements you don’t need.

Favorites will only show on this page if the user has favorited posts. Here is what the page looks like with three posts favorited by the user.

favorite button

That’s it!

Final Thoughts

The good thing about the favorites plugin is that it is designed for developers, but this can also be challenging for those not comfortable with a little html/css. But for Divi, it seems to be a nice option to get the favorite button functionality up and running without too much customization. There are more options and shortcodes available if you want to add more functionality so feel free to check those out.

It goes without saying that this plugin will work for many different use cases, not just for favoriting animals for an animal shelter. This would also work well for traditional blog posts or products.

I look forward to hearing from you in the comments.

Cheers!

Divi Black-friday Sale

It's The Divi Black Friday Sale! Save Big For A Limited Time πŸ‘‡

Save big on Divi and Divi products for a limited time.

Access The Sale
Divi Black-friday
Premade Layouts

Check Out These Related Posts

Divi 5 Update: Public Alpha Version 4

Divi 5 Update: Public Alpha Version 4

Posted on November 25, 2024 in Divi Resources

The Divi 5 Public Alpha is available for testing. If you use Divi 5, you’ll notice an update notification for Public Alpha Version 4 today. We release new Divi 5 versions every two weeks, and it gets better each time! If you haven’t tested Divi 5 yet, try it and let us know what you...

View Full Post
New Starter Site for Freelancers (Quick Install)

New Starter Site for Freelancers (Quick Install)

Posted on November 24, 2024 in Divi Resources

Divi empowers you to build the best websites possible, and now, Divi Quick Sites takes website creation to a whole new level. This revolutionary tool lets anyone, regardless of skill level, generate a complete website in under two minutes! Divi Quick Sites provides everything you need to launch...

View Full Post

12 Comments

  1. Hello! thank you for this tutorial, is there a way to make the favourite list as a grid and not a stacked list?

  2. I just wanted to alert everyone that the plugin has been updated and also includes opt-in checkbox for GDPR compliance. I guess this blog must have generated downloads and gotten the author’s attention)

  3. Nice plugin, but updates are a problem

  4. Outdated plugin but interesting concept.

  5. Very detailed tutorial!
    Lot’s of work went into writing this post.

    Only thing, as Commenter: Michael stated, I also noticed that Favorites plugin has not been updated for 12 months and only tested in WP 4.8.6.

    Isn’t this normally a Red Flag as far installing this plugin?

    • That can easily be a red flag for me.

      • Same here.
        Please don’t recommend outdated plugins.

  6. It looks like the https://wordpress.org/plugins/favorites/ plugin has Not been supported in over a year and support request are saying it’s not working properly or at all on some sites.

    It shows 1 out of 10 support tickets resolved in the past 2 months and that one request was resolved by the person requesting help on that issue.

    Is there another up to date plugin that will work to do the same thing and work with Divi?

    • It has been updated.

  7. Very cool. But when I read this:
    “Once a user clicks on a button to favorite a post, the post is saved (using cookies) and is able to be listed anywhere on your site using a shortcode.”
    All I could think was, “GDPR…GDPR…” Sigh

  8. Nice one thanks πŸ™‚ The same can be applied for the real estate layout I quess right?

  9. This is really cool, but I wish more of these tutorials had less plugins and more code.

Leave A Reply

Comments are reviewed and must adhere to our comments policy.

πŸ‘‹ It's The Divi
Black Friday Sale!
Get The Deal
Before It's Gone!
Join To Download Today