Back to contents

JetEngine: How to Add Terms to Data Store

 

This tutorial will teach you how to create data stores for terms with the JetEngine WordPress plugin.

With the Data Store module, you can create pages like “Favorites” or “Wishlist,” where users can add liked items and come back to them anytime. Check our video tutorial to learn more about Data Store and all its features.

In this tutorial, we will explain how to create and set up a data store for terms.

1 Step — Creating a Data Store

Go to the admin control panel and open JetEngine > JetEngine dashboard. Enable the Data Stores module and press the “Save” button.

jetengine wordpress plugin dashboard

After enabling the module, you will see the new tab in the JetEngine dashboard – Data Stores. Proceed to it and click the “New Store” button.

jetengine data store

You can get the overview of all Data Store features here in the “1 Step”.

NOTE!
Select another store type if you choose the Local Storage store type for the terms data store and have a filtering issue with the data store terms in the Listing Grid.

When you are done with creating the store, hit the “Save” button.

2 Step — Creating a “Favorites” Page

Go to the Dashboard > Pages and hit the “Add New” button. Name and save the new page for favorite terms.

page for terms data store

3 Step — Creating Listing for Taxonomy, Add and Remove Buttons

To find out how to create a listing for taxonomy, go through our tutorial.

Create the first listing for terms and add the “Add to Favorites” button. Check the detailed guide on how to create this button here in the “3 Step”.

Create another listing item and add the “Remove from Favorites” button. About that, you can read here in the “4 Step”.

4 Step — Adding the Code to the Child Theme

To make the terms data store work, you need to add the code to your active theme.

NOTE!
We strongly recommend performing all the changes with codes directly in the child theme. It is because the parent theme can drop all the set changes after the update. The child theme will not do it, and what is more, after the update for the parent theme, it will inherit the updated features.

Also, we recommend making a backup of your website before any changes. If something goes wrong, you will be able to roll back to the earlier website version.

Go to the Appearance > Theme Editor. In the Theme Files menu on the right side, open the functions.php tab.

edit child theme PHP functions

Copy the code from GitHub and paste it at the end of the file.

add code to the child theme

In this line replace ‘cookies-store’ with your actual Data Store slug.

if ( 'cookies-store' !== $store->get_slug() ) {

For example, it would be:

if ( 'favorites' !== $store->get_slug() ) {

And in this line replace ‘category’ with your required taxonomy slug:

$terms = wp_get_post_terms( $current_object->ID, 'category', array( 'fields' => 'ids' ) );

After you finish, click on the “Update File” button.

5 Step — Creating a Terms Query via JetEngine Query Builder

Proceed to JetEngine > Query Builder and press the “Add New” button. Give your new query a Name and choose the “Terms Query” Query Type.

In the General tab, select the name for the Taxonomy for your data store.

create terms query with jetengine query builder

In the Include/Exclude tab, click the Dynamic Tags icon on the right of the Include field and choose the Get store macro from the list.

include/exclude

Then select the name of your store for the term data store and press the “Apply” button. In the end, push the “Add Query” button.

6 Step — Customizing the “Favorites” Page

Return to the “Favorites” page and proceed to edit it with Elementor. Drag and drop the Listing Grid widget on the page. Then choose the second created listing with the “Remove from Favorites” button in the Listing drop-down menu.

edit jetengine listing grid

The next step is opening the Custom Query tab. Enable the Use Custom Query toggle and choose the name of the created terms query in the Custom Query selector.

use custom query

After you finish customizing and stylizing the “Favorites” page, push the “Update” button.

Then place another Listing Grid on any other page, and in the Listing drop-down menu, choose the first created listing with the “Add to Favorite” button. Customize the page as per your needs and hit the “Update” button.

After adding a few terms to Favorites, you can go to the “Favorites” page and check if the chosen terms are already there.

jetengine listing grid with remove from favorite button

If you would like to know how to add an item counter and a “likes” counter, follow this tutorial and proceed to the “5 Step” and “6 Step”.

Also we the separate tutorial about the “Recently Viewed” section in Data Stores.

That’s it. You now know how to create and set up a “Favorites” page for terms with the JetEngine Data Store module.