Forums Forums Search & Filter Pro Results permalinks with category

Viewing 7 posts - 1 through 7 (of 7 total)
  • Anonymous
    #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
    #215406

    Did 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;).

    Anonymous
    #215494

    Thanks Trevor. Yes I have both those options on and the taxonomy is in the form.

    Trevor
    #215521

    Are 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).

    Anonymous
    #215555
    This reply has been marked as private.
    Trevor
    #215557

    AH… 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/ OR http://myboats.com/boats/boat_type/boat-name/

    It cannot predictably have one like:

    http://myboats.com/boats/catamaran/boat_name/ OR http://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/ OR http://myboats.com/boats/boat_type/catamaran/ OR http://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) to boats, 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?

    Anonymous
    #215565

    Okay thanks for the detailed explanation Trevor.

Viewing 7 posts - 1 through 7 (of 7 total)