Support » Plugin: Polylang » Make my custom post types multilingual

  • Resolved rodrigopestana



    I’ve been trying to figure out how to make my custom post types multilingual from the Polylang documentation… and I just can’t.

    I’m “code challenged” so I really don’t get it.

    I’ve just installed a new theme on my website that puts portfolio custom posts on the Home Page (through a static page) but I can’t make this work in the non-default language.

    Can you provide any extra guidance on how to solve this or point me to any other documentation on this matter?

    Thank you for your time and congratulations for the great plugin.

    The website is (for the default language: portuguese) and (for english).

    PS – Actually, I don’t really need to have multilingual versions of the portfolio custom posts since I’m not displaying them as individual pages. They’re just there to fill the Home Page. So a work around making it possible to associate different portfolio posts to the two versions of the static page (pt and en) that make each of the Home Pages would make me happy.

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


    You need to add this in a custom plugin or in the functions.php of a child theme:

    add_filter('pll_get_post_types', 'my_pll_get_post_types');
    function my_pll_get_post_types($types) {
    	return array_merge($types, array('my-cpt' => 'my-cpt'));

    where I suppose that your post type is called ‘my-cpt’

    Thanks for your quick answer!

    I assume this solution is meant to allow the translation of the portfolios.

    Unfortunately, I had no success.

    I created the following my-plugin.php file, put it in /wp-content/plugins and then activated it:

    Plugin Name: My Plugin for Polylang
    add_filter('pll_get_post_types', 'my_pll_get_post_types');
    function my_pll_get_post_types($types) {
    	return array_merge($types, array('portfolio' => 'portfolio'));

    Still, there was no option to translate on the Portfolios admin page.

    Should I expect something else?

    I also tried to add the code to the theme functions.php file but the site broke down.

    Can you tell me what I’m doing wrong?

    Thanks again!

    PS – In case it helps, I’m doing the tests here:

    I just tested turning off all other plugins and it still does not work for me.

    Can’t change the theme because I’ll loose the custom post types.

    I look forward to hearing from you.


    Plugin Author Chouby


    I don’t know this theme so I am bit blind…

    It seems that this theme does not use standard interface provided by WordPress to display the admin pages for this custom post type.

    Polylang can hook in two points:
    *The posts list table (where Polylang adds the languages column)
    *The Edit post page (where Polylang adds a metabox)

    But in both cases, if the custom post type interface is not standard and does not use the same actions and filters as WordPress, then I am affraid there is now way for Polylang to add its own interface.

    Maybe you can try this (not very convenient…). In the address bar of your browser, type directly the url yoursite/wp-admin/post-new.php?post_type=portfolio&from_post=nnn&new_lang=en where nnn is the post id of the portuguese post you want to translate. I wonder if it will works…

    It worked! 🙂

    Thank you so much.

    I’ll check with Themezilla if they can address this from their side but at least I have an english homepage, now.

    Great support, Chouby!

    Plugin Author Chouby


    Just in case it helps, for the list table, I use the filter ‘manage_posts_columns’ and the action ‘manage_posts_custom_column’ to create the new columns with the languages.

    And for the metabox in the ‘edit post’ admin panel, I just use the function ‘add_meta_box’

    Great! Thanks.

    I’ll post on their support forum and will come back with the answer.


    Here’s the Themezilla reply to this situation:

    It works! 🙂


    Plugin Author Chouby


    Unfortunately, only your post is publicly visible, not the answer from Themezilla… Could you post it here?

    Oh! I’m sorry.

    I assumed the details of the answer would only interest Themezilla/Blox clients (and those, of course, have access to the full thread).

    But I guess you deserve to see it, too… 😉

    Hmm. We do edit the columns, and maybe there is a bit of conflict. We add a bit of information that probably isn’t all that important. In posttype-portfolio.php comment out this section of code, and see if that is the conflict:

    function zilla_edit_columns_portfolio($portfolio_columns){
    	$portfolio_columns = array(
    		'cb' => '',
    		'title' => _x( 'Title', 'column name', 'zilla' ),
    		'thumbnail' => __( 'Thumbnail', 'zilla')
    	return $portfolio_columns;
    add_filter('manage_edit-portfolio_columns', 'zilla_edit_columns_portfolio');  
    function zilla_custom_columns_portfolio($portfolio_columns, $post_id){  
    	switch ($portfolio_columns) {
    	    case 'thumbnail':
    	        $thumbnail_id = get_post_meta( $post_id, '_thumbnail_id', true );
    	        if( $thumbnail_id ) {
    	            $thumb = wp_get_attachment_image( $thumbnail_id, 'portfolio-admin-thumb', true );
    	        if( isset($thumb) ) {
    	            echo $thumb;
    	        } else {
    	            echo __('None', 'zilla');
    add_action('manage_posts_custom_column',  'zilla_custom_columns_portfolio', 10, 2);

    Thanks again for the great support!

    Plugin Author Chouby


    Yes that is the function ‘zilla_edit_columns_portfolio’ which conflicts. It overwrites the columns created previously by WordPress and plugins.

    A better function would be:

    function zilla_edit_columns_portfolio($portfolio_columns){
    	$portfolio_columns['cb'] = ''; // as done in previous function
    	$portfolio_columns['thumbnail'] = __( 'Thumbnail', 'zilla');
    	unset($portfolio_columns['date']); // removes the date normally added by WordPress
    	return $portfolio_columns;

    There is no need to remove comments, author and taxonomies columns if the portfolio post type is registered without supporting them.

    Hopefully, this will not only help Themezilla/Blox clients as the way this filter is used here is quite frequently found in themes and plugins using post types (and this prevents other plugins using the same filter to work correctly)

    Better still! It’s always good to know other people can benefit, too. 🙂

    Adding this filter to the functions.php of my child theme worked for me.

    add_filter('pll_get_post_types', 'my_pll_get_post_types');
    function my_pll_get_post_types($types) {
    	return array_merge($types, array('services' => 'services'));

    My post type was called services.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Make my custom post types multilingual’ is closed to new replies.