I am in the final stages of completing a site built using Toolset and Elementor and have (with some help from you) created a dynamic site that with several custom post types and taxonomies that do just what we want them to do - apart from the last CPT and I hope you can help with the following three issues. I have tried to describe the issues as clearly as possible but please let me know if anything is unclear or if you have any other questions.
BACKGROUND
I have created a custom post type called ‘Destinations’ and a hierarchical taxonomy for destinations archive pages.
The taxonomy hierarchy is based on
-Continent
- -Country
- - - City / Region
- - - - Local area / Village / Town
The ‘Destinations’ pages contain info about each destination we cover as well as two other sections
- Explore destinations in current taxonomy (ie children to the taxonomy/destination shown on the page)
- most recent properties in ‘Destination’ (from the ‘properties for sale’ custom post type)
QUESTIONS / ISSUES
- DESTINATIONS ARCHIVE
hidden link
hidden link
(THE SITE IS STILL PASSWORD PROTECTED - ACCESS DETAILS ARE USER: tga PW: Krit@45
Question 1.
Is there a way to show the destinations only one level down, ie Europe (the first of the two links above) should only show France and Spain
And
Spain (the second of the two links above) should only show Madrid
- CUSTOM POST TYPE PAGES
hidden link
Scroll down to the second section - Property destination cut: Spain
Question 2.
Here are all taxonomies included but I would like to only see Spain, ie in this case Madrid. Or even better, instead of taxonomies, featured images and link to the Destinations pages that are associated with taxonomy children to Spain
Question 3.
On the same page as for question 2, scroll down to the third section ‘Most recent properties for sale in ….’
The idea is to only show properties for sale in the selected destination, ie in this case the most recent properties added to the custom post type ‘Properties for sale’ in Spain (hidden link)
Best regards / john
Dear John
I have tried the credentials you provided above, I can see only a htaccess login window, so I have to download your duplicator package to test it in my localhost, will update here if there is anything found
There are lots of questions in this thread, I am trying to answer them one by one
Question 1.) please open the URL you mentioned above:
For example:
hidden link
This is archive page of term "Europe", but you are using a Elementor template + a normal post view to display the main content, it will conduct other unexpected results.
I suggest you try these:
1) Remove/trash the Elementor template "Property destinations":
hidden link
2) Follow our document to setup a Views WordPress archive for "Property destinations" taxonomy archive page
https://toolset.com/documentation/getting-started-with-toolset/customize-post-archives/designing-an-archive-without-any-page-builder/
3) Edit each 'Destinations' posts, make sure you have enabled only "city" child term for those problem posts, for example post "Nice":
hidden link
in section "Property destinations", it should enable only term "Nice"
4) Use WordPress built-in action hook "pre_get_posts" to exclude those posts with only child term, for example, add below codes into your theme file "functions.php":
function non_hierarchical_func( $query ) {
if ( ! is_admin() && $query->is_main_query() &&is_tax('property-destination-taxonomy') ) {
$tax_query = $query->tax_query->queries;
$tax_query[0]['include_children'] = 0;
$query->set( 'tax_query', $tax_query );
}
return;
}
add_action( 'pre_get_posts', 'non_hierarchical_func', 99 );
Question 2.) Same as above, you can try these:
1) edit the post "Spain"
hidden link
make sure enable only term "Spain"
2) Edit the taxonomy view "Destinations taxonomy archive view":
hidden link
in section "Query Filter", change the filter to:
Taxonomy is set by the page where this View is inserted
see screenshot taxonomy-filter.JPG
And test again
Question 3.) Same as above, you can edit the post view "Properties - most recent view":
hidden link
in section "Query Filter", add a filter as below:
Taxonomy is set by the page where this View is inserted
Thank you for your message.
Read your comment re the login details - I have re-checked and I am able to log in to both wp and ftp with the details I sent you so not sure why it does not work. Remember that the site is password protected so first you have to get access to the domain – user: tga password: Krit@45
An alternative, if that would be useful, is that I create a staging copy of the site.
Anyhow, unfortunately I have not been very successful – see my comments below.
What do you suggest – would be a shame to give up on the last feature on the site but maybe this is more difficult than I expected so let me know what you think.
Question 1
1. Done (was already in the trash but was still associated with the destinations taxonomy.
2. 'setup a Views WordPress archive for "Property destinations" taxonomy archive page’
Below is a link to a short video as I get a different result compared to what is described on the page you sent the link to.
video: hidden link
3. Done
4. Added but no change.
Question 2
1. Done
2. Done – no change
Question 3
Done but not working
Please let me have your thoughts.
Best regards / john
Thanks for the details, I can login into your website now.
All the steps I mentioned above work fine in my localhost with your duplicator package, if you need more assistance for those problems, I need your permission to do those changes in your website, please backup your website first.
Dear Luo,
I confirm the site is backed up your help in solving the questions would be much appreciated so you have my permission to do the suggested changes to the site.
Suggest that instead of editing "Properties - most recent view" as suggested in Question three, duplicate the view and then do the changes as the current view is used in a different template.
Please let me know if you have any questions or require any further info.
Best regards / john
1) trash this elementor template: "Destinations archive properties"
hidden link
2) Create a wordpress archive "Property destinations archive page":
hidden link
3) Add the same custom PHP codes into your theme file functions.php:
hidden link
4) Edit post "France", enable term "Europe"
hidden link
Test it in front-end:
hidden link
You will be able to see the France post in the result,
Same as other "Europe" country posts, you can enable the term "Europe" for them.
Please check it, confirm if it is what you want, then we can proceed to other questions. thanks
I will handle them one by one tomorrow morning.
Dear Luo,
Thank you very much - this structure is exactly what I had in mind .
Two questions
1.
As far as I understand it, the archive page is not related to a 'Toolset view' or to an 'Elementor template'? Where should I start digging in order to get rid of the sidebar and get it to look similar to the other archive pages, e.g hidden link
I have updated the 'wordpress archive' you created so the image is correctly sized and the text details are correct.
2.
As you will see, I changed the custom post type url - I had named it 'destination-cpt' to make it easier to keep track of the url and it is now just 'destination'. That is also the reason why the taxonomy name is 'property-destination-taxonomy'. Tried to rename it 'property-destination' but realised that updating the taxonomy url and change the code in 'functions.php' is not sufficient - where in addition do I need to update the code.
Is there anything I can do to help you help me?
Best regards / john
Question 2.
Here are all taxonomies included but I would like to only see Spain, ie in this case Madrid. Or even better, instead of taxonomies, featured images and link to the Destinations pages that are associated with taxonomy children to Spain
In your case, I suggest you try hierarchical custom post type, for example:
1) Edit the post type "Property destinations":
hidden link
enable below two options:
- Page Attributes
- hierarchical
2) Edit the single those city posts of post type "Property destination", for example "Madrid":
hidden link
In section "Page Attributes", option "Parent" choose "Spain" post.
3) change the taxonomy view "Destinations taxonomy archive view" to post view:
- query posts of post type "Property destinations"
- filter by:
Select posts whose parent is the page where the View is shown.
- display the post informations:
[wpv-post-featured-image]<br />
[wpv-post-link]
Test it in front-end:
hidden link
You should be able to see child post "Madrid" in section "Property destination"
Please confirm the workaround, then we can proceed to question 3
For other new questions, please check the new thread here:
https://toolset.com/forums/topic/archive-page-and-custom-post-type-url-questions/
Luo,
Thank you for your messages.
The Question 2 workaround structure is also looking very good. I plan to implement the changes . you suggested for the url and layout later today / over the weekend. Does it make any difference to you if I implement the changes before or after you look into Q3?
Many thanks and have a nice weekend / john
Yes, as I mentioned above, we can handle the questions one by one.
Question 3.
Since in your website, there are two post types:
- Property destination
- Properties for sale
One "Property destination" post can connect to multiple "Properties for sale" posts
One "Properties for sale" post can connect to only one "Property destination" post,
So I suggest you try these:
1) setup one-to-many relationship between post types "Property destination" and "Properties for sale":
hidden link
Edit each "Properties for sale" post, relate with a "Property destination" post, for example: "An extraordinary property with flawless design ... "
hidden link
see section "Property destination property for sale"
2) Edit the post view "Properties-destinations-most-recent-view"
hidden link
Change the filter to:
Select posts in a Property destinations Properties for sale relationship that are related to the Post where this View is shown.
Test the result again:
You should be able to see the result: "An extraordinary property with flawless design ... "
Dear Luo,
Many thanks for your message and solution which works but is not ideal when the site grows and it does not take the location hierarchy into consideration. But there may be another way to do this so continue to read and let me know what you think.
1. Add the 'property locations' taxonomy to the 'Destinations' post type - see attachment A.
2. Use the 'properties-most recent view' in the that is related to the property locations taxonomy - scroll down to the bottom of this page - hidden link - and / or look at the Elementor 'property destinations page' template.
The only problem with this approach is an issue I thought I had solved a long time ago but apparently wishful thinking and that problem is that this solution is also not taking the hierarchy into consideration and you may want me to open a new ticket for this - please let me know if you do.
To explain, go to hidden link and scroll down to the bottom of the page (or see attachment B). As you will see, the 'most recent' selection of properties include not only properties in the same destination as property the view is shown in but all destinations in France such as the Alps.
Is there a way to get the view to only show the most recent in the same location as the property the view is shown in? If yes, the problem with 'most recent properties' should be solved for both the property page and the destinations page.
3 questions
- is it possible?
- is it a good solution?
- should I open a new ticket?
Best regards / john