WooCommerce: Add Content To Archive With Multiple Filter Attributes
I want to add some SEO content to some of my archives.
For example:
I have a category called "Sportcars". It's easy to add some content thereby adding it to the category archive page.
But I also want some content on the archive where I filter by "Sportcars" (product category), "Cabrio" (attribute) and "black" (attribute).
The URL looks something like this:
domain.com/products/sportcars/?filter_type=cabrio&filter_color=black
Is there any way to address such an archive?
I'm thinking about something to do with the URL parameters. But I couldn't figure out a good solution.
Maybe there is a way to rewrite the URL to add some ID's for the category and the filters and use them to build a custom post type with a slug based on ID's. I can then search for the post type and display. it's content. But maybe the filters are in different orders sometimes!?
For example here's what I mean:
domain.com/products/100/?filter_type=200&filter_color=300
Now the Custom Post Type slug is something like this (not visible in the frontend):
/seo-content/100-200-300/
Is this possible? Or is there a better way? I searched a lot and couldn't find anything.
Answer
An easy way to get the job done without messing with custom slugs and archives is to use a php if statement in your archive checking if the values posted is "cabrio" & "black" like this:
$filter_type = $_GET[filter_type];
$filter_color = $_GET[filter_color];
if ( (isset($filter_type) == 'cabrio') && (isset($filter_color) == 'black') )
{
//your content here
} else {
//your content here
}
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?