Help Center

How to Add Terms to Data Store

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.

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

Creating a Data Store

Go to the admin control panel, proceed to JetEngine > JetEngine > Data Stores, and click the “New Store” button.

jetengine data store

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

Warning

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.

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

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”.

Adding the Code to the Child Theme

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

Warning

Before proceeding with the tutorial′s steps, create a backup or replicate the actions on the staging site. The backup ensures the website restoration if an error occurs. To learn more, proceed to the How to Backup and Restore a WordPress Website with a Plugin article.

Go to 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 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.

Creating the Terms Query via the 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 tab of the terms query full

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.

macros get store

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.

add to favorite terms

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

terms in favorite page

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 have a 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.

Was this article helpful?
YesNo

Need help?

Ask Facebook community

Get answers from 22K Crocoblock Community experts from all over the world.

Start a live chat

Ask question to support agent and share its details via chat messages.