I am working on a simple custom post type with several custom taxonomies. Using ACF I have created fields where the user can select a single value for each of the custom taxonomies.

Here is my custom post type and custom taxonomy.

add_action('init', 'pj_product_opt');
function pj_product_opt() {
        register_post_type( 'product', array(
                'labels' => array(
                        'name' => 'Products',
                        'singular_name' => 'Product'
                ),
                'description' => 'Products',
                'public' => true,
                'menu_position' => 20,
                'supports' => array('title', 'editor', 'custom-fields'),
                'menu_icon' => 'dashicons-album'
        ));

        register_taxonomy(
                'product_manufacturer',
                'product',
                array(
                        'labels' => array(
                                'name' => __( 'Manufacturers'),
                                'singular_name' => __('Manufacturer'),
                                'add_new_item' => __('Add New Manufacturer'),
                                'edit_item' => __('Edit Manufacturer'),
                                'new_item' => __('New Manufacturer'),
                                'search_items' => __('Search Manufacturers')
                        ),
                        'rewrite' => array('slug' => 'product_manufacturer'),
                        'hierarchical' => false
                )
        );

I am trying to achieve URLs like the following: /products/%manufacturer-slug%/%product-slug%

Remember - the value for the manufacturer field is currently in a custom field I have defined and assigned to the product post type. Anything similar to that allowing manufacturers appear as part of the hierarchy would be great. Any advice would be excellent.

Might be a stupid question, but have you tried creating the Custom Taxonomies using the GUI via the plugin?

I only ask because I recently had problems creating custom taxonomies for a restaurant website via php functions. I could only get it to work if I used the GUI.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.