admin管理员组文章数量:1122846
I'm building a WordPress site using Elementor Pro and Advanced Custom Fields (ACF). I have two custom post types: Countries (for country pages) and Sights (for different sights/landmarks in each country). I’ve also created a custom taxonomy called "Countries" that’s assigned to both the Countries post type and the Sights post type.
Each Country post has an associated country term (e.g., "Moldova," "Estonia"), and each Sight post is tagged with the country it belongs to using the same taxonomy. I want to display a list of Sights on each Country page, but only those that match the current country.
The URL structure is like this: /countries/moldova/ (for Moldova's page), and I want to display only the Sights that belong to Moldova on the Moldova page, and similarly, Estonia sights on the Estonia page.
What I’ve tried so far is using the Elementor Pro Post Widget and filtering by taxonomy terms, but this requires me to manually set the term, which defeats the purpose of a dynamic template. I’ve also tried using FacetWP to filter the Sights, but I still can’t figure out how to make the filter dynamically pull the country from the URL and match it with the taxonomy term of the Sights.
How can I dynamically filter Sights by country on each Country page based on the URL, using Elementor Pro (or FacetWP), without manually setting the term for each page? I want the template to work for any country page and automatically display the corresponding Sights. Is there a way to achieve this dynamically, preferably without custom coding, or do I need a code snippet?
本文标签: How to Dynamically Filter Custom Post Types by Taxonomy Based on URL in Elementor Pro and ACF
版权声明:本文标题:How to Dynamically Filter Custom Post Types by Taxonomy Based on URL in Elementor Pro and ACF? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736284209a1927200.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论