I'm trying to display related posts in Toolset from Elementor via custom query ID.
I need help to figure out how can I use the API function toolset_get_related_posts inside Elementor custom query filter to retrieve related posts (children).
Documentation from Elementor: hidden link
I have read in a different thread that Elementor doesn't support Toolset Relationships API, is this correct?
I just tried this out on a local site and I found it works.
I assume you are adding the Elementor posts widget to an Elementor template for the parent post type, and the posts widget is set to show child posts. You want to modify the query so that it only shows child posts of the currently displayed parent post, rather than all child posts.
In the Elementor post widget you need to add a Query ID, which is a string used to create a custom action that you will use to trigger your code.
In the screenshot you can see I used "ts_mod_elem_query" for my query ID.
I then added the following code snippet, which in my case is to filter child "task" posts from a "project-task" relationship based on the currently displayed parent "project".
Are we talking about the section "Recetas adicionales"?
This has nothing to do with the Elementor posts module and the Elementor documentation you shared, it is a Toolset View, and it looks like you already added a relationship Query Filter to that View to show recetas related to the current "especial".
So when visiting the especial post "Tortilla de Patatas" that View outputs the same receta posts which you can see connected to the especial post in the backend.
I'm not sure if I'm looking at the right thing, can you clarify what the problem is, because it looks like this is already set up correctly to me.
I have already related posts via Toolset views as you can see in the section RECETAS RELACIONADAS.
However, this is a very clunky process as I have to copy and paste Elementor HTML code into the Toolset View which means that I have no control over any of the visuals shown on the page and that's one of the reasons the recipes on the list look terrible.
I want to show exactly the same list of related posts with an Elementor custom query so that I can apply the style and functionality that comes out of the box with Elementor easily.
I added an Elementor post module to the template and used a version of the above code to try and modify the resulting query, but it didn't work, even though it does on my local test site.
It will be easier for me to debug this locally, so I'm taking a copy of your site and I'll update you again with my findings.
It worked on my local copy (though I did notice a lot of PHP notices arising from code you added to your child theme you may want to investigate), so I tried again on your live site and it is working, if you want to check.
(The template still has the View before the Posts module.)
The code is added at Toolset > Settings > Custom Code.