Support Forum
Support › MB Custom Post Type › Custom post type keeps redirecting me to homepage (301)
https://staging.gardenliving.pl/marka/roolf-living/ - keeps redirecting to home page with 301.
I have flushed link structure. There is no redirection plugin active.
<div>
<?php
add_action( 'init', 'your_prefix_register_post_type' );
function your_prefix_register_post_type() {
$labels = [
'name' => esc_html__( 'Marki', 'your-textdomain' ),
'singular_name' => esc_html__( 'Marka', 'your-textdomain' ),
'add_new' => esc_html__( 'Add New', 'your-textdomain' ),
'add_new_item' => esc_html__( 'Add new marka', 'your-textdomain' ),
'edit_item' => esc_html__( 'Edit Marka', 'your-textdomain' ),
'new_item' => esc_html__( 'New Marka', 'your-textdomain' ),
'view_item' => esc_html__( 'View Marka', 'your-textdomain' ),
'view_items' => esc_html__( 'View Marki', 'your-textdomain' ),
'search_items' => esc_html__( 'Search Marki', 'your-textdomain' ),
'not_found' => esc_html__( 'No marki found', 'your-textdomain' ),
'not_found_in_trash' => esc_html__( 'No marki found in Trash', 'your-textdomain' ),
'parent_item_colon' => esc_html__( 'Parent Marka:', 'your-textdomain' ),
'all_items' => esc_html__( 'All Marki', 'your-textdomain' ),
'archives' => esc_html__( 'Marka Archives', 'your-textdomain' ),
'attributes' => esc_html__( 'Marka Attributes', 'your-textdomain' ),
'insert_into_item' => esc_html__( 'Insert into marka', 'your-textdomain' ),
'uploaded_to_this_item' => esc_html__( 'Uploaded to this marka', 'your-textdomain' ),
'featured_image' => esc_html__( 'Featured image', 'your-textdomain' ),
'set_featured_image' => esc_html__( 'Set featured image', 'your-textdomain' ),
'remove_featured_image' => esc_html__( 'Remove featured image', 'your-textdomain' ),
'use_featured_image' => esc_html__( 'Use as featured image', 'your-textdomain' ),
'menu_name' => esc_html__( 'Marki', 'your-textdomain' ),
'filter_items_list' => esc_html__( 'Filter marki list', 'your-textdomain' ),
'filter_by_date' => esc_html__( '', 'your-textdomain' ),
'items_list_navigation' => esc_html__( 'Marki list navigation', 'your-textdomain' ),
'items_list' => esc_html__( 'Marki list', 'your-textdomain' ),
'item_published' => esc_html__( 'Marka published', 'your-textdomain' ),
'item_published_privately' => esc_html__( 'Marka published privately', 'your-textdomain' ),
'item_reverted_to_draft' => esc_html__( 'Marka reverted to draft', 'your-textdomain' ),
'item_scheduled' => esc_html__( 'Marka scheduled', 'your-textdomain' ),
'item_updated' => esc_html__( 'Marka updated', 'your-textdomain' ),
'text_domain' => esc_html__( 'your-textdomain', 'your-textdomain' ),
];
$args = [
'label' => esc_html__( 'Marki', 'your-textdomain' ),
'labels' => $labels,
'description' => '',
'public' => true,
'hierarchical' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'show_in_rest' => true,
'query_var' => true,
'can_export' => true,
'delete_with_user' => true,
'has_archive' => true,
'rest_base' => '',
'show_in_menu' => true,
'menu_position' => 12,
'menu_icon' => 'dashicons-editor-ol',
'capability_type' => 'page',
'supports' => ['title', 'thumbnail', 'excerpt', 'editor'],
'taxonomies' => ['oferta'],
'rewrite' => [
'with_front' => false,
],
];
register_post_type( 'marka', $args );
}</div>
Problem disappears when I deactivate Woocommer, but it's a must have there. If I can't solve I may have to go with just pages and extra fields.
May it be the issue that the custom posts name/slugs are the same as some attributes or tags in some products?
Hi,
There is no issue on my site when activating WooCommerce and creating a new post type marka
. I think there is another issue with redirection on your site. Please try again with a fresh install and let me know if it works.
Well the fresh install will not help me much, as I have to redo the shop with products, orders, etc.
I will just use pages with additional fields. Maybe I will find a better solution in the future.
Do you know what types of redirection may be caused by woocommerce?
Hi,
I do not experience any issue with redirection when activating WooCommerce. You can try to contact Woo support to ask for help with this issue.