• Resolved johnespindola

    (@johnespindola)


    Hi, thanks for this great plugin.
    I have an issue, when I activate the plugin, shows a 404.
    I’m using Custom Post Type Permalinks plugin, to set the structure /%product_type%/%postname%.
    Here is my CPT code (I don’t know if I have any seeting that creates a conflict):

    register_post_type(‘product’,
    array(
    ‘labels’ => array(
    ‘name’ => __( ‘Products’ ),
    ‘singular_name’ => __( ‘Product’ ),
    ‘menu_name’ => __( ‘Products’ ),
    ‘name_admin_bar’ => __( ‘Products’ ),
    ‘add_new’ => __( ‘Add New’ ),
    ‘add_new_item’ => __( ‘Add New Product’ ),
    ‘new_item’ => __( ‘New Product’ ),
    ‘edit_item’ => __( ‘Edit Product’ ),
    ‘view_item’ => __( ‘View Product’ ),
    ‘all_items’ => __( ‘All Product’ ),
    ‘search_items’ => __( ‘Search Product’ ),
    ‘parent_item_colon’ => __( ‘Parent Product:’ ),
    ‘not_found’ => __( ‘No Products found.’ ),
    ‘not_found_in_trash’ => __( ‘No Products found in Trash.’ )
    ),
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘menu_icon’ => ‘dashicons-media-spreadsheet’,
    ‘capability_type’ => ‘page’,
    ‘hierarchical’ => false,
    ‘rewrite’ => array(“slug” => “product”, ‘with_front’ => false ),
    “query_var” =>”true”,
    “query_var_slug” =>””,
    ‘supports’ => array(‘title’,’thumbnail’,’editor’, ‘custom_fields’, ‘excerpt’),
    ‘publicly_queryable’ => true,
    ‘exclude_from_search’ => false,
    ‘has_archive’ => true,
    ‘taxonomies’ => array(‘product_type’)
    )
    );

    Hope you can help me. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author kubiq

    (@kubiq)

    Hello,

    sorry I totally missed your message.

    It’s not a good idea to use product post type, because many plugins expect this to be WooCommerce product (eg. RankMath), but that’s not the problem in here.

    It’s also important how you register your product_type taxonomy, because I don’t see anything wrong with your register_post_type code…

    Is it still not working?

    Thread Starter johnespindola

    (@johnespindola)

    Hello,
    No problem, I haven’t been able to find a solution to this problem yet.
    I hadn’t thought about what you’re saying about using “products” as the cpt name ?? … but, maybe an error could be occurring with the taxonomy declaration … maybe I’m missing something … could you help me checking it, please?

    register_taxonomy(
    'product_type',
    'product',
    array(
    'labels' => array(
    'name' => 'product Types',
    'add_new_item' => 'Add Type',
    'new_item_name' => "New Type"
    ),
    'show_ui' => true,
    'show_tagcloud' => false,
    'hierarchical' => true,
    'args' => array( 'orderby' => 'term_order' ),
    'rewrite' => array( 'slug' => 'product-category', 'with_front' => false ),
    'query_var' => false,
    'capabilities' => array('manage_terms' => 'edit_pages')
    )
    );

    Plugin Author kubiq

    (@kubiq)

    Can you try to use CPT UI instead of manual code?

    Everything works for me.

    I have taxonomy term external:
    https://demo.kubiq.sk/product_type/external/

    and here is my product post:
    https://demo.kubiq.sk/external/xxx/

    These are my Permalinks settings:
    https://i.imgur.com/FPtfa9P.png

    Here is code export from CPT UI:

    function cptui_register_my_cpts_product() {
    
    	/**
    	 * Post Type: Products.
    	 */
    
    	$labels = [
    		"name" => esc_html__( "Products", "twentytwentythree" ),
    		"singular_name" => esc_html__( "Product", "twentytwentythree" ),
    		"menu_name" => esc_html__( "Products", "twentytwentythree" ),
    		"all_items" => esc_html__( "All Products", "twentytwentythree" ),
    		"add_new" => esc_html__( "Add new", "twentytwentythree" ),
    		"add_new_item" => esc_html__( "Add new Product", "twentytwentythree" ),
    		"edit_item" => esc_html__( "Edit Product", "twentytwentythree" ),
    		"new_item" => esc_html__( "New Product", "twentytwentythree" ),
    		"view_item" => esc_html__( "View Product", "twentytwentythree" ),
    		"view_items" => esc_html__( "View Products", "twentytwentythree" ),
    		"search_items" => esc_html__( "Search Products", "twentytwentythree" ),
    		"not_found" => esc_html__( "No Products found", "twentytwentythree" ),
    		"not_found_in_trash" => esc_html__( "No Products found in trash", "twentytwentythree" ),
    		"parent" => esc_html__( "Parent Product:", "twentytwentythree" ),
    		"featured_image" => esc_html__( "Featured image for this Product", "twentytwentythree" ),
    		"set_featured_image" => esc_html__( "Set featured image for this Product", "twentytwentythree" ),
    		"remove_featured_image" => esc_html__( "Remove featured image for this Product", "twentytwentythree" ),
    		"use_featured_image" => esc_html__( "Use as featured image for this Product", "twentytwentythree" ),
    		"archives" => esc_html__( "Product archives", "twentytwentythree" ),
    		"insert_into_item" => esc_html__( "Insert into Product", "twentytwentythree" ),
    		"uploaded_to_this_item" => esc_html__( "Upload to this Product", "twentytwentythree" ),
    		"filter_items_list" => esc_html__( "Filter Products list", "twentytwentythree" ),
    		"items_list_navigation" => esc_html__( "Products list navigation", "twentytwentythree" ),
    		"items_list" => esc_html__( "Products list", "twentytwentythree" ),
    		"attributes" => esc_html__( "Products attributes", "twentytwentythree" ),
    		"name_admin_bar" => esc_html__( "Product", "twentytwentythree" ),
    		"item_published" => esc_html__( "Product published", "twentytwentythree" ),
    		"item_published_privately" => esc_html__( "Product published privately.", "twentytwentythree" ),
    		"item_reverted_to_draft" => esc_html__( "Product reverted to draft.", "twentytwentythree" ),
    		"item_scheduled" => esc_html__( "Product scheduled", "twentytwentythree" ),
    		"item_updated" => esc_html__( "Product updated.", "twentytwentythree" ),
    		"parent_item_colon" => esc_html__( "Parent Product:", "twentytwentythree" ),
    	];
    
    	$args = [
    		"label" => esc_html__( "Products", "twentytwentythree" ),
    		"labels" => $labels,
    		"description" => "",
    		"public" => true,
    		"publicly_queryable" => true,
    		"show_ui" => true,
    		"show_in_rest" => true,
    		"rest_base" => "",
    		"rest_controller_class" => "WP_REST_Posts_Controller",
    		"rest_namespace" => "wp/v2",
    		"has_archive" => true,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"delete_with_user" => false,
    		"exclude_from_search" => false,
    		"capability_type" => "post",
    		"map_meta_cap" => true,
    		"hierarchical" => false,
    		"can_export" => false,
    		"rewrite" => [ "slug" => "product", "with_front" => true ],
    		"query_var" => true,
    		"supports" => [ "title", "editor", "thumbnail", "excerpt", "custom-fields" ],
    		"show_in_graphql" => false,
    	];
    
    	register_post_type( "product", $args );
    }
    
    add_action( 'init', 'cptui_register_my_cpts_product' );
    
    function cptui_register_my_taxes_product_type() {
    
    	/**
    	 * Taxonomy: Product Types.
    	 */
    
    	$labels = [
    		"name" => esc_html__( "Product Types", "twentytwentythree" ),
    		"singular_name" => esc_html__( "Product Type", "twentytwentythree" ),
    		"menu_name" => esc_html__( "Product Types", "twentytwentythree" ),
    		"all_items" => esc_html__( "All Product Types", "twentytwentythree" ),
    		"edit_item" => esc_html__( "Edit Product Type", "twentytwentythree" ),
    		"view_item" => esc_html__( "View Product Type", "twentytwentythree" ),
    		"update_item" => esc_html__( "Update Product Type name", "twentytwentythree" ),
    		"add_new_item" => esc_html__( "Add new Product Type", "twentytwentythree" ),
    		"new_item_name" => esc_html__( "New Product Type name", "twentytwentythree" ),
    		"parent_item" => esc_html__( "Parent Product Type", "twentytwentythree" ),
    		"parent_item_colon" => esc_html__( "Parent Product Type:", "twentytwentythree" ),
    		"search_items" => esc_html__( "Search Product Types", "twentytwentythree" ),
    		"popular_items" => esc_html__( "Popular Product Types", "twentytwentythree" ),
    		"separate_items_with_commas" => esc_html__( "Separate Product Types with commas", "twentytwentythree" ),
    		"add_or_remove_items" => esc_html__( "Add or remove Product Types", "twentytwentythree" ),
    		"choose_from_most_used" => esc_html__( "Choose from the most used Product Types", "twentytwentythree" ),
    		"not_found" => esc_html__( "No Product Types found", "twentytwentythree" ),
    		"no_terms" => esc_html__( "No Product Types", "twentytwentythree" ),
    		"items_list_navigation" => esc_html__( "Product Types list navigation", "twentytwentythree" ),
    		"items_list" => esc_html__( "Product Types list", "twentytwentythree" ),
    		"back_to_items" => esc_html__( "Back to Product Types", "twentytwentythree" ),
    		"name_field_description" => esc_html__( "The name is how it appears on your site.", "twentytwentythree" ),
    		"parent_field_description" => esc_html__( "Assign a parent term to create a hierarchy. The term Jazz, for example, would be the parent of Bebop and Big Band.", "twentytwentythree" ),
    		"slug_field_description" => esc_html__( "The slug is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.", "twentytwentythree" ),
    		"desc_field_description" => esc_html__( "The description is not prominent by default; however, some themes may show it.", "twentytwentythree" ),
    	];
    
    	
    	$args = [
    		"label" => esc_html__( "Product Types", "twentytwentythree" ),
    		"labels" => $labels,
    		"public" => true,
    		"publicly_queryable" => true,
    		"hierarchical" => true,
    		"show_ui" => true,
    		"show_in_menu" => true,
    		"show_in_nav_menus" => true,
    		"query_var" => true,
    		"rewrite" => [ 'slug' => 'product_type', 'with_front' => true, ],
    		"show_admin_column" => false,
    		"show_in_rest" => true,
    		"show_tagcloud" => false,
    		"rest_base" => "product_type",
    		"rest_controller_class" => "WP_REST_Terms_Controller",
    		"rest_namespace" => "wp/v2",
    		"show_in_quick_edit" => false,
    		"sort" => false,
    		"show_in_graphql" => false,
    	];
    	register_taxonomy( "product_type", [ "product" ], $args );
    }
    add_action( 'init', 'cptui_register_my_taxes_product_type' );
    Thread Starter johnespindola

    (@johnespindola)

    Hello.
    I have tried adding the configurations that you sent me and everything works fine.
    I really thank you very much ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘404 error’ is closed to new replies.