WordPress.org

Ready to get started?Download WordPress

Forums

Polylang
[resolved] polylang for custom post types stops working in 1.4dev17 (10 posts)

  1. X_Y
    Member
    Posted 7 months ago #

    Hi,
    I noticed the "pll_get_post_types" action for adding custom post types stops working in the development version (1.4dev17).

    My custom post types are not registered by polylang by default, there are no translation options available. So I added them through "pll_get_post_types" action and it works in latest production version 1.3.1, but not in 1.4dev17

    The original method is described here:
    http://wordpress.org/support/topic/make-my-custom-post-types-multilingual?replies=14

    http://wordpress.org/plugins/polylang/

  2. Chouby
    Member
    Plugin Author

    Posted 7 months ago #

    I don't have this issue. However I changed some things around this. The filter is called now only one time quite soon in the process. Maybe before you create it.

    How do you use the 'pll_get_post_types' ?

  3. X_Y
    Member
    Posted 7 months ago #

    I used it as described in the link above, in functions.php

    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 my-cpt is my custom post type.

  4. Chouby
    Member
    Plugin Author

    Posted 7 months ago #

    I see. This change was not a good idea if the filter is not reachable from functions.php. The new development version 1.4dev19 should solve the issue. Thanks for your tests!

  5. X_Y
    Member
    Posted 7 months ago #

    It would be better if custom post types are detected by default, so you don't have to go through this step :)

  6. Chouby
    Member
    Plugin Author

    Posted 7 months ago #

    They are! You just have to check the relevant option in Polylang settings to decide if you want to enable language and translations management or not.

  7. X_Y
    Member
    Posted 7 months ago #

    Ahh I see! That really helps a lot. However the first thing I get from google search is the approach above. And why not have custom post types activated by default?

  8. Chouby
    Member
    Plugin Author

    Posted 7 months ago #

    However the first thing I get from google search is the approach above.

    Perhaps because it's the oldest way. The checkbox is available since 1.0 (about one year ago), whereas the filter is available since 0.8 (about one year before).

    And why not have custom post types activated by default?

    To avoid conflicts with some plugins / themes

  9. X_Y
    Member
    Posted 7 months ago #

    OK, I hope people will get this point. Thanks a lot!

  10. Chouby
    Member
    Plugin Author

    Posted 7 months ago #

    I changed again the code around the 'pll_get_post_types' filter, trying to avoid calling it too much time and keep it compatible with themes.

    It must now be added before the action 'after_setup_theme' is fired. For a theme it means that it must be added directly in functions.php as you do.

    The modification is done in current development version (1.4dev20).

Reply

You must log in to post.

About this Plugin

About this Topic

Tags