Expose Custom Categories to Search API JSON - GHK Recipes
This document is focused around the GHK Recipe app functionality, however it can be used for other clients who want a similar setup. The purpose of this document is to outline the steps needed to add custom taxonomy data to the feed, so that they are available as custom facets in search and also available in the search API JSON in the buckets..
This is important for Good housekeeping Recipes, as a third party company presents some of the content in the app, and not PugPig. This content is iFramed into the app, this includes the cooking modal which can be found on the article templates, and their recipe picker timeline which is their primary timeline.
Step 1
Adding Custom Taxonomy
This is the first step when adding a new custom taxonomy, it first has to be registered in WordPress using the register_taxonomy function on the init hook, this happens in the Taxonomy.php file. However, all that's needed in order to add a new custom taxonomy is to add it to the CUSTOM_TAXONOMIES
array in the Constants.php file. We loop through that array and create the taxonomies, using the key as the taxonomy slug and the value as the taxonomy name.
Step 2
Adding the custom taxonomies as categories using the pugpig_widget_taxonomies
hook.
This is important because it adds the our custom taxonomy as a category to the feed which exposes it to search so that it can be accessible via our search api. This is a mandatory step in order to show the custom taxonomy terms as facets as bolt search uses this value.
Step 3 - Follow the steps in the search configuration options do
Add the custom-taxonomy.json file to the extra files to deploy.
This is covered in the search configuration options document.
Step 4
Step 5 (Optional)