Skip Navigation

[Resolved] Associating a WordPress Tag With a Custom Archive

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by chrisB-30 5 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#1238126

Hello Again,

I have custom post type "Brides"
With the Taxonomy "Locations"

I am displaying entries in a grid on each of the "Location" custom archives for multiple countries:

Latin
Cuba
Colombia
Peru
Asia
China
Philippines
Thailand

Here is a sample: hidden link

I would like to add a 'Related Posts" grid to the bottom of the pages using Elementors new related post block. But to do this the Archive would need to have a wordpress tag associated with it for Elementor to read.

I have many standard wordpress posts that relate to each of the "Location" custom archives which I have tagged with wordpress tags (ie, Thailand, Colombia, China) and I would like to display them at the bottom of the archives pages.

Is there an easy or semi-easy way to do this?

Thanks!

#1238160

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Chris

I took a look at the Elementor posts widget, and I read the Elementor announcement blog post, and to be honest unless I'm missing something about how it works, I'm not sure of the point of it, because it seems like you manually have to specify the terms to include/exclude, rather than it being inferred from the context (e.g. the current term of the archive being viewed with this template).

I'm not quite sure which posts you want to display as related posts.

If you are on the kazakhstan-brides archive you linked to then that will list all of the bride posts with that term. Which brides do you want to display in the related posts section?

Other brides from where? Anywhere but Kazakhstan, or somewhere else?

#1238165

Actually, the Elementor related query works pretty well - like on this post:
hidden link
At the bottom where it says
More From
Romance Tours

That is a related query set to "categories" - so it only shows posts from the same category as the current post. It can also be set to "Tag" so that it only shows posts with the same tag as the current post.

So, if I tagged my post with "Ukraine" it shows all other posts with the tag Ukraine.

I would like to use that same functionality - but on a custom toolset archives.

But I don't want to show entries from the "Brides" post type - I want to show regular WordPress posts. For instance - on the Ukraine archive - hidden link

I would like the Related Post grid to show WordPress posts that I have tagged with "Ukraine" like these:
hidden link

Hope that makes sense...

Let me know if it's hopeless and I'll just put a "Featured Articles" grid instead.

#1238540

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Chris

Maybe it's because I'm used to Toolset, but I can't get the "Related" option for the Posts module to display anything meaningful at all (and Elementor haven't updated their documentation yet to describe how it works).

I make a sandbox test site with a very simple set up that you are welcome to look at: hidden link (no login credentials required).

Note, I just have Types and Elementor (incl Pro) plugins.

I made a custom post type "Stuff" and added a custom taxonomy "Locations" to it with a few countries, and I added tags to posts with the same countries.

I made one Elementor template for the locations archive.

You can see it on the front-end here: hidden link

If you edit the template you'll see the first section is the archive, which correctly displays "stuff" posts with the Japan location term.

The second section has a Posts module with "related" setting that I can't get to work. Feel free to edit and update to demonstrate how it should, it would be useful to know.

The third section just takes a Posts module which is set to display standard posts with a tag of "Japan".

I had to set this tag manually, and I guess this is the crux of your question. Can you set the tag dynamically, based on the archive term.

Well, evidently no.

But. In the Query section you can manually set a Query ID to allow server side filtering.

So, much like we provide hooks such as wpv_filter_query to modify Views filters, it seems Elementor provide something similar to modify these queries.

You'll need to try their support for help with that if you can't work it out from their documentation.

Note that I don't have Views active on this test site. And there is nothing I've done with Types that you couldn't do by manually registering the post type and taxonomies, so I think it really is a question for Elementor.

(But do let me know if you have anything useful to share about that related posts widget.)

#1238603

Looks like the related post query will only work on single templates, which makes sense.

I agree this looks more like a question for the Elementor guys.

Actually, Elementor sent me some code a while back for my functions.php to create a custom related posts query for the single templates, before they released it in their core. So, perhaps they have already figured this one out.

Thanks again.

Ill let you know if they have a solution.