• Hi,
    I’m having troubles when using your plugin to show filtered custom post types with translated taxonomy and translated taxonomy terms. I’m using WPML string translation to translate the taxonomies slugs and the taxonomy terms slugs.

    My custom post type plugin looks like the following:

    <?php 
    /*
     * Plugin Name: Arblu Products
     * Author: Filippo Vigani
     * Text Domain: arblu-products
     */
    if(!function_exists('arblu_product_init')):
    /* Register arblu product custom post type */
    function arblu_product_init(){
    	$labels = array(
    		'name' => __('Products', 'arblu-products'),
    		'singular_name' => __('Product', 'arblu-products'),
    		'add_new' => _x('Add new', 'product', 'arblu-products'),
    		'add_new_item' => __('Add new Product', 'arblu-products'),
    		'edit_item' => __('Edit Product', 'arblu-products'),
    		'new_item' => __('New Product', 'arblu-products'),
    		'view_item' => __('View Product', 'arblu-products'),
    		'view_items' => __('View Products', 'arblu-products'),
    		'search_items' => __('Search Products', 'arblu-products'),
    		'not_found' => __('No Products found', 'arblu-products'),
    		'not_found_in_trash' => __('No Products found in Trash', 'arblu-products'),
    		'all_items' => __('All Products', 'arblu-products'),
    		'archives' => __('Products Archives', 'arblu-products'),
    		'attributes' => __('Products Attributes', 'arblu-products'),
    		'parent_item_colon' => __('Parent Product', 'arblu-products')
    	);
    
    	$args = array(
    		'labels' => $labels,
    		'description' => 'Arblu Product',
    		'public' => true,
    		'menu_position' => 5,
    		'capability_type' => 'post',
    		'supports' => array('title', 'thumbnail', 'custom-fields'),
    		'has_archive' => true,
    		'rewrite' => array(
    			'slug' => __('products', 'arblu-products'),
    			'with_front' => true
    		)
    	);
    
    	register_post_type('arblu-product', $args);
    	
    	register_taxonomy('typology', 'arblu-product',
    					  array(
    						  'labels' => array(
    							  'name' => __('Products typologies', 'arblu-products'),
    							  'singular_name' => __('Product typology', 'arblu-products'),
    							  'all_items'         => __( 'All typologies', 'arblu-products'),
    							  'edit_item'         => __( 'Edit typology', 'arblu-products'),
    							  'update_item'       => __( 'Update typology', 'arblu-products'),
    							  'add_new_item'      => __( 'Add New typology', 'arblu-products'),
    							  'new_item_name'     => __( 'New typology Name', 'arblu-products'),
    							  'menu_name'         => __( 'Typology', 'arblu-products')
    						  ),
    						  'query_var' => __('typology', 'arblu-products'),
    						  'show-ui' => false,
    						  'meta_box_cb' => false,
    						  'show_admin_column' => true,
    						  
    						  'rewrite' => array(
    							  'slug' => __('typology', 'arblu-products'),
    							  'with_front' => true
    						  )
    					  )
    					 );
    	register_taxonomy_for_object_type('typology', 'arblu-product');
    
    	register_taxonomy('family', 'arblu-product',
    					  array(
    						  'labels' => array(
    							  'name' => __('Products families', 'arblu-products'),
    							  'singular_name' => __('Product family', 'arblu-products')
    						  ),
    						  'query_var' => __('family', 'arblu-products'),
    						  'show-ui' => false,
    						  'meta_box_cb' => false,
    						  'show_admin_column' => true,
    						  'rewrite' => array(
    							  'slug' => __('family', 'arblu-products'),
    							  'with_front' => true  /* permalink with_front true: /products/family/otto */
    						  )
    					  )
    					 );
    	register_taxonomy_for_object_type('family', 'arblu-product');
    	
    	$shower_cabin_taxonomies = array(
    			array('taxonomy' => 'shower-cabin-opening', 'name' => 'Shower cabin openings', 'singular_name' => 'Shower cabin opening'),
    			array('taxonomy' => 'shower-cabin-shape', 'name' => 'Shower cabin shapes', 'singular_name' => 'Shower cabin shape'),
    			array('taxonomy' => 'shower-cabin-category', 'name' => 'Shower cabin categories', 'singular_name' => 'Shower cabin category', 'arblu-products'),
    			array('taxonomy' => 'shower-cabin-accessory-typology', 'name' => 'Shower cabin accessory typologies', 'singular_name' => 'Shower cabin accessory typology')
    		);
    	$shower_tray_taxonomies = array(
    			array('taxonomy' => 'shower-tray-material', 'name' => 'Shower tray materials', 'singular_name' => 'Shower tray material')
    		);
    	$bathroom_furniture_taxonomies = array(
    			array('taxonomy' =>'bathroom-furniture-typology', 'name' => 'Bathroom furniture typologies', 'singular_name' => 'Bathroom furniture typology')
    		);
    	$bathroom_covering_taxonomies = array(
    			array('taxonomy' =>'bathroom-covering-category', 'name' => 'Bathroom covering categories', 'singular_name' => 'Bathroom covering category')
    		);
    	$decorative_radiator_taxonomies = array(
    			array('taxonomy' =>'decorative-radiator-category', 'name' => 'Decorative radiator categories', 'singular_name' => 'Decorative radiator category')
    		);
    	
    	foreach(array_merge($shower_cabin_taxonomies,$shower_tray_taxonomies,$bathroom_furniture_taxonomies,$bathroom_covering_taxonomies,$decorative_radiator_taxonomies) as $taxonomy){
    		register_taxonomy($taxonomy['taxonomy'], 'arblu-product',
    					  array(
    						  'labels' => array(
    							  'name' => __($taxonomy['name'], 'arblu-products'),
    							  'singular_name' => __($taxonomy['singular_name'], 'arblu-products')
    						  ),
    						  'query_var' => __($taxonomy['taxonomy'], 'arblu-products'),
    						  'show-ui' => false,
    						  'meta_box_cb' => false,
    						  'rewrite' => array(
    							  'slug' => __($taxonomy['taxonomy'], 'arblu-products'),
    							  'with_front' => true
    						  )
    					  )
    					 );
    		register_taxonomy_for_object_type($taxonomy['taxonomy'], 'arblu-product');
    	}
    }
    endif;
    add_action('init', 'arblu_product_init');
    
    add_filter( 'post_row_actions', 'remove_row_actions', 10, 2 );
    
    function remove_row_actions( $unset_actions, $post ) {
      global $current_screen;
    
    	if ( $current_screen->post_type != 'arblu-product' ) return $unset_actions;
      	//unset($unset_actions['edit']);
      	//unset($unset_actions['view']);
      	//unset($unset_actions['trash']);
      	unset($unset_actions['inline hide-if-no-js']);
    
    	return $unset_actions;
    }
    
    /* Rewrite flush so there's no need to refresh permalinks manually */
    //NOTE: Doesn't work if installed as a Must Use Plugin
    if(!function_exists('arblu_products_rewrite_flush')):
    function arblu_products_rewrite_flush(){
    	arblu_product_init();
    	flush_rewrite_rules();
    }
    endif;
    register_activation_hook( __FILE__, 'arblu_products_rewrite_flush' );
    ?>

    The settings of the plugin are the default ones. All the strings have been translated.

    On a related note, even if it’s not the main subject of the topic, I noticed that when no results are found the filter module isn’t displayed. Is this the intended behaviour?

    The page I need help with: [log in to see the link]

  • The topic ‘Filtered pages with WPML-translated taxonomy slug and terms slugs respond w/ 404’ is closed to new replies.