Forums › Forums › Search & Filter Pro › Results permalinks with category
- This topic has 6 replies, 2 voices, and was last updated 5 years, 4 months ago by Anonymous.
-
Anonymous(Private) July 2, 2019 at 6:08 am #215398
Hi,
I have a site where I’ve used S&F Pro to filter a custom post type using the Post Type Archive method to show the results.
I’d now like to be enable the category to show in the permalink for each item so it would have for instance boats/boat-category/single-boat rather than boats/single-boat.
This works well when using the WooCommerce Shop method with products. I realise this may be something to do with the custom post type config which has:
'has_archive' => true, 'hierarchical' => true, 'public' => true, 'rewrite' => array( 'slug' => 'boats', 'with_front' => false ),
Thanks
Trevor(Private) July 2, 2019 at 9:20 am #215406Did you follow the steps outlined in this post:
https://support.searchandfilter.com/forums/topic/dynamic-search-url/#post-215365
The steps are the same for the WooCommerce and Post Type Archive method, but the category/taxonomy MUST also be in the form (even if you hide it with custom CSS (
display: none;
).Trevor(Private) July 3, 2019 at 10:55 am #215521Are you able to send me a live link/URL to your search page so I can take a look?
Can you suggest a search for me to make and let me know what the URL IS and SHOULD BE?
Be aware that some SEO plugins change the slug in the way you describe (removing the parent category slug).
Trevor(Private) July 4, 2019 at 6:54 am #215557AH… I understand.
You were right to be wonder if it is possible to reliably structure the permalink like that, and I am sorry to say it is not. WordPress is not structured that way. A post (a boat in your case) can only reliably have a URL with the post type in it, such as:
http://myboats.com/boats/boat_name/
ORhttp://myboats.com/boats/boat_type/boat-name/
It cannot predictably have one like:
http://myboats.com/boats/catamaran/boat_name/
ORhttp://myboats.com/boats/boat_type/catamaran/boat_name/
Why I didn’t get what you wanted earlier I do not know, for which I apologize. The issue is that Taxonomies are stored as arrays and can have multiple values, even if you only ever use one. If you can keep the taxonomy term down to one term per post, then it would become predictable. The other issue is that our search can only go to the archive page, even if that page might have only one result, and so the URL cannot have the name of the boat, so, in the above example, the URL of the results page can only ever be as long as:
http://myboats.com/boats/catamaran/
ORhttp://myboats.com/boats/boat_type/catamaran/
ORhttp://myboats.com/boat_type/catamaran/
WordPress allows you to include or omit the taxonomy name in the URL. Generally, you should avoid having a single taxonomy used by more than one Post Type. In the last example set, you can see that, as
boat_type
should only belong (in this case) toboats
,boats
is not necessary in the URL, but is good from an SEO point of view.I hope I now understand you correctly and have this right?
-
AuthorPosts