• Resolved jmayoff

    (@jmayoff)


    I thought I found what I was looking for, when I found this post from a few months ago, but sadly it didn’t help.

    https://www.ads-software.com/support/topic/polylang-and-custom-post-types

    I’m using a theme that has a custom post type called Slides. I want to be able to have different slides for different languages (English, French), the way French and Englisy posts and pages can be associated with each other.

    The above link states

    You just have to register your post type as usual for example in a function hooked to the ‘init’ action. If you register it with ‘show_ui’ set to true, then it is automatically created with multilingual support.

    The post type is registered with ‘show_ui’ set to true, but there’s no option in the Dashboard to associate slides of different languages (as with regular posts. Also, I’m not sure if the function is hooked to the ‘init’ action. Here it is:

    /*-----------------------------------------------------------------------------------*/
    
    /*	Create a new post type called slides
    
    /*-----------------------------------------------------------------------------------*/
    
    function bnk_register_post_type_slides() 
    
    {
    
    	$labels = array(
    
    		'name' => __( 'Slides','bhinneka'),
    
    		'singular_name' => __( 'Slide','bhinneka' ),
    
    		'rewrite' => array('slug' => __( 'Slides','bhinneka' )),
    
    		'add_new' => _x('Add New', 'Slide'),
    
    		'add_new_item' => __('Add New Slide','bhinneka'),
    
    		'edit_item' => __('Edit Slide','bhinneka'),
    
    		'new_item' => __('New Slide','bhinneka'),
    
    		'view_item' => __('View Slide','bhinneka'),
    
    		'search_items' => __('Search Slides','bhinneka'),
    
    		'not_found' =>  __('No slides found','bhinneka'),
    
    		'not_found_in_trash' => __('No slides found in Trash','bhinneka'), 
    
    		'parent_item_colon' => ''
    
    	  );
    
    	  $args = array(
    
    		'labels' => $labels,
    
    		'public' => true,
    
    		'publicly_queryable' => true,
    
    		'show_ui' => true, 
    
    		'query_var' => true,
    
    		'rewrite' => true,
    
    		'capability_type' => 'post',
    
    		'hierarchical' => false,
    
    		'menu_position' => 5,
    
    		'supports' => array('title','thumbnail','custom-fields')
    
    	  ); 
    
    	  register_post_type(__( 'slide','bhinneka' ),$args);
    
    }

    https://www.ads-software.com/extend/plugins/polylang/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Things have changed since that time. Now you should find an option in Polylang settings to activate the language and translation management for this post type. It should work if the action is “hooked to an init action”.

    In the code it should look like this:

    add_action('init', 'bnk_register_post_type_slides');

    So if you can’t find the checkbox in Polylang settings, try finding where ‘bnk_register_post_type_slides’ elsewhere in the theme’s code.

    Finally, I believe that’s not a good idea to write:

    register_post_type(__( 'slide','bhinneka' ),$args);

    It is better not to enable translation for something which is never displayed but used internally by WordPress. It can work on a monolingual site, but it will likely break in a multilingual site. You should change this to:

    register_post_type('slide', $args);

    Thread Starter jmayoff

    (@jmayoff)

    I found it in the Settings. I should have looked there first. Thanks for the quick reply.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Post Types’ is closed to new replies.