Hi
I am creating a website with one to many relationship between a post type called Parks (one) and a post type called Park Homes (many). The relationship I have set up for this is called "Park to Park Homes"
I have created a content type to display a single Park (Parks post type). This page has a link off to another page that will show all Park Homes (Park Home post type) related to that Park.
The Park page link is created in javascript to include a query string parameter that uses the current Park "post id". So, the link to the Park Homes page looks something like: /park-homes/?wpv-relationship-filter=211 where 211 is the post id for the current "Park"
The Park Homes page has a view of Park Homes. This is filtered using a query filter: Select posts in a Park to Park Homes relationship that are related to the Post with ID set by the URL parameter wpv-relationship-filter.
Basically this is working but I have two problems.
1. If you navigate to the /park-homes/ page without applying the wpv-relationship-filter parameter that page displays all Park Home posts. Shouldn't it display no posts if the query string parameter is null?
2. More importantly, I am trying to add sorting options to the /park-homes/ page. I have added sorting options and set the sort to apply without re-loading the page. The idea being that once on the page, the user could apply a custom sort within the displayed Park Homes. However, applying a new sort (even with sort set to not reload page) clears the query filter (and removes the query string parameter from the url).
Is there a way around this or a better way to achieve this functionality?
i.e. I want to go from a page displaying a "Park" to a page displaying all "Park Homes" belonging to that "Park". Once on the "Park Homes" page I want to be able to apply a custom sorting without losing the view query filter.
Hello. Thank you for contacting the Toolset support.
1. If you navigate to the /park-homes/ page without applying the wpv-relationship-filter parameter that page displays all Park Home posts. Shouldn't it display no posts if the query string parameter is null?
==>
By default, view displays all results before you apply the filter that means when the view is loaded first. If you do not want to display any results until the filter is selected we have workaround. If you can share problem URL and access details I am happy to look at it.
2. More importantly, I am trying to add sorting options to the /park-homes/ page. I have added sorting options and set the sort to apply without re-loading the page. The idea being that once on the page, the user could apply a custom sort within the displayed Park Homes. However, applying a new sort (even with sort set to not reload page) clears the query filter (and removes the query string parameter from the url).
==>
I will require to review this issue if you can share problem URL and access details.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.\
I have set the next reply to private which means only you and I have access to it.
Yes that is working. Thank you. However, the sorting on the /homes-for-sale/ page is not working correctly.
If you go to /homes-for-sale/?wpv-relationship-filter=211 first of all the page displays ok. If you modify the sort by selection twice, the "?wpv-relationship-filter=211" parameter is removed from the url and the page now shows no homes.
As I said, the sort is configured to not refresh the entire page.
It is not worth to sort with only one entry as it does not make any sense.
May I kindly ask you to add few records to your page /homes-for-sale/?wpv-relationship-filter=211 , maybe at least 5 records so I can check whats the issue.
I just tried to reproduce the issue with my local test install and with my test site the filtering and sorting works just fine and when I change the sorting option the URL is updated with URL param as expected.
In order to minimise the cause cause of the issue and possible conflict with theme or other third party plugins:
Could you please try to resolve your issue by deactivating all third-party plugins as well as the default theme to check for any possible conflicts with any of the plugins or themes?
- Do you see any difference?
What if you try to create a brand new view to display your related posts and check if that helps?
I have deactivated third party plugins and switched over to a default wordpress theme. I still see the problems.
For the sorting control, there are two options for how the sorting is applied:
Reload the page
Without reloading the page.
I had selected "Without reloading the page". In this case, I see the operation I described before, i.e.
Navigate to "/homes-for-sale/?wpv-relationship-filter=211". The page displays correctly with default sorting and shows 4 post items.
Change sort field to be "Field - Price". The page updates with correct sorting. However, at this point the query string parameter "wpv-relationship-filter=211" is already removed from the url.
Change sort direction. The page now updates and shows no items.
I also tried with the Apply sorting option changed to "Reload the page". In this case, I see the following:
Navigate to "/homes-for-sale/?wpv-relationship-filter=211". The page displays correctly with default sorting and shows 4 post items.
Change sort field to be "Field-Price". The page now reloads but shows no items. If I look at the url it is now showing:
The original query string parameter of wpv-relationship-filter=211 has been removed.
So, in both cases, "Reload the page" or "Without reloading the page" the sorting control is not respecting the original query string parameter of wpv-relationship-filter=211 when the page updates. This parameter is essentially being removed.
I think I have fixed the issue. The solution seems to be to go to Toolset>Settings>Front-end Content and click to "enable history management settings for AJAX custom search".
Then if I choose to Apply sorting "without reloading the page", the page seems to work ok.