Skip Navigation

[Resolved] Custom feed to list properties in a state

This support ticket is created 4 years, 2 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.

Our next available supporter will start replying to tickets in about 1.13 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 4 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1456669

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.

#1457289

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

#1463465

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.

#1463545

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.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.