Help Center

Recreating Pinterest or TikTok Algorithm with Recommended Posts

Modern platforms such as Pinterest, Instagram, and TikTok are known for their algorithms that promote posts similar to those you have opened or liked. The same logic can be implemented on the WordPress site using the JetEngine's Query Builder and Data Store modules.

Before you start, check the tutorial requirements:

Create a Data Store

The system’s logic will be built on the Data Store principle. To build a new Data Store, move to WordPress Dashboard > JetEngine > JetEngine > Data Stores and click the “+ New Store” button. 

Enter the store’s Name and Slug (“Favourite Jobs” in our case). Select the “User Metadata” Store Type and set the needed Max size. We also enable the Count items toggle.

data store created

Click the “Save” button.

Adjust a Terms Query

Proceed to WordPress Dashboard > JetEngine > Query Builder and click the “Add New” button. 

Enter the Name for the query and select the “Terms QueryType

Select the required Taxonomy. In the Object/Post IDs field, choose the “Get store” option after clicking the “Dynamic Tag” icon, and in the newly opened pop-up, select the Data Store you created. Click the “Apply” button.

terms query settings

Save the query once you are ready.

Set up a Posts Query

Now, create one more query. Enter the Name and select the “Posts QueryType.

Select the needed Post Type and choose the “Published (publish)” Post Status

posts query created

Proceed to the Tax Query tab and click the “Add new” button. For the Taxonomy field, select the same taxonomy you used in the previous “Terms Query”. Choose the “Term ID” option in the Field input. 

Click the “Dynamic Tag” next to the Terms field and select the “Query Results” option. In the newly opened pop-up, select the “Terms Query” you created earlier for the Query field, and choose the “List of items IDs” option for the Return input. Click the “Apply” button. Put the “IN” option for the Compare operator.

tax query settings of the posts query

Now, move to the Post & Page tab and choose the “Get store” option in the Post Not In field. Select the Data Store created in the first step and click the “Apply” button. 

posts not in settings in the posts query

Open the Pagination tab and in the Posts Per Page field set the desired number of posts shown on the page at once. If you need to show all available posts, set the value to “-1”.

posts per page set up in the posts query

Save the changes once you are ready. 

Create a Listing Template

Following the How to Create a Listing Template for Post Types in Elementor guide, we create a Listing Template that displays the recommended posts.

listing template created

An essential element in this listing is a Data Store Button widget. As an alternative, the Dynamic Link widget can be used for our purpose. In this case, select the “Add to store” Source and set the required store. In our example, we also added the heart-shaped icon and set the Labels.

dynamic link settings

Click the “Publish” button once you are ready with the settings.

In this case, our aim is to display the recommended posts on the user’s Profile page. So, we open the Account Page template.

Add the Listing Grid widget to the template opened in editing mode. In the Listing dropdown, select the Listing Template you created earlier. Add any other needed settings.

listing grid added to the page

In the Custom Query tab, enable the Use Custom Query toggle and select the “Posts Query” you created earlier.

posts query applied to the listing grid

Click the “Publish” button. 

Check the Results

Now, we proceed to the page with all the available jobs and save one, for example, in London.

saved a post

Then we open the Account page and see that among the recommended posts, only those in the same category — jobs in London — appear.

posts of the same category are displayed on the front

That’s it. Now you know how to recreate the Pinterest or TikTok logic, and display recommended posts from the same category, as users liked using the WordPress JetEngine plugin. 

Was this article helpful?
YesNo

Need help?

Ask Facebook community

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

Start a live chat

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