Hi. I am tried to create a custom feed to list properties in a state.
I am using this template: hidden link so States area a custom post type, not a custom field.
So, how could I get this feed? For example to see last 10 properties in Arizona.
Thanks.
Hello,
You can try to pass URL parameter "post_type=post-type-slug" to WordPress feed URL, like this:
hidden link
More help:
https://core.trac.wordpress.org/ticket/12943
Yes, this work fine. But I don't need only a feed for "houses". I need for houses in california for example.
Can I do that?
thanks.
There isn't such kind of built-in feature within Toolset plugins, you will consider custom codes, for example:
1) pass two URL parameters "post_type" and "parent-state" to WordPress feed URL, like this:
post_type=houses&parent-state=california
2) Setup PHP codes, use action hook pre_get_posts to trigger a PHP function:
https://developer.wordpress.org/reference/hooks/pre_get_posts/
3) In this PHP function
- check if it is in feed and is main query, and have those two URL prameters
https://developer.wordpress.org/reference/classes/wp_query/is_feed/
https://developer.wordpress.org/reference/classes/wp_query/is_main_query/
- Get the state post ID by URL parameter "parent-state"
- Use state post ID to add post type relationship filter to query:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#new-approach
For your reference.