• Resolved brian1037

    (@brian1037)


    Polylang is a very popular localization plugin:

    https://en-ca.ww.wp.xz.cn/plugins/polylang/

    For my example, I have a custom post type with the slug “product”, and three taxonomies registered to the “product” CPT.

    I’ve set Polylang to translate the CPT and its taxonomies.

    Now, when I use Simple Taxonomy Ordering to reorder any one of the three taxonomies, I run into major issues.

    1. Any WP_Query for the “product” CPT will result in incorrect permalinks when using get_permalink() within that secondary loop (the permalinks are missing the language slug).

    2. When WP is doing ajax (DOING_AJAX = true), any WP_Query for “product” will fail and simply return results for the primary language set in Polylang.

    3. Deactivating (and even completely deleting) the plugin only fixes issue #1. Unfortunately issue #2 doesn’t get fixed. I suspect that the plugin does not clean up after itself once it’s deleted.

    So my question is, how do I undo what this plugin has done to the database? If deleting the plugin doesn’t purge what it’s done to the database, then would it be possible for a quick and dirty explanation on what needs to be undone so that I can fix it manually?

    Thank you for your time.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @brian1037,

    Sorry about that. I will look into this later today and hopefully get back to you with a solution.

    Kevin.

    • This reply was modified 9 years, 2 months ago by yikesitskevin.
    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @brian1037,

    You’re using the free version of Polylang, correct? Not the PRO version?

    Thread Starter brian1037

    (@brian1037)

    Yup, the free version. I should’ve included more details in the first post.

    Plugins:
    YIKES Simple Taxonomy Ordering 1.2.4
    Polylang 2.1.2 (free version)

    Wordpress 4.7.3 set up as a network, with 4 additional sites installed. The sites are configured as sub-domains. I don’t think this is part of the issue though.

    To reproduce the issue, create a template with this code

    <?
    // Template name: Test template
    
    $posts = new WP_Query(array(
    	'post_type' => 'product', // or any post type with taxonomies who's orders are managed by Simple Taxonomy Ordering
    	'posts_per_page' => -1
    ));
    
    if( $posts->have_posts() ) : while( $posts->have_posts() ) : $posts->the_post();
    
    	echo get_permalink() . '<br>';
    
    endwhile; endif;

    With Simple Taxonomy Ordering disabled, you get the correct permalinks. For example, it would be http://example.com/en/product/product-slug.

    But, when Simple Taxonomy Ordering is enabled, and is configured to reorder a taxonomy registered to the post type, then the URL’s turn into this: http://example.com/product/product-slug. The language slug disappears.

    Thanks again for your time

    • This reply was modified 9 years, 2 months ago by brian1037.
    • This reply was modified 9 years, 2 months ago by brian1037. Reason: typo
    • This reply was modified 9 years, 2 months ago by brian1037.
    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    I really appreciate the detailed post. What I’m doing should be equivalent, but I’m not seeing the http://example.com/en/product/{product-slug} coming through.

    I have a home page template, and I set my home page to be static, pointing towards my template. I also sent polylang to translate the home page (so it goes to http://www.mylocalenv.dev/en or http://www.mylocalenv.dev/es).

    I’m fetching a CPT with taxonomies (ordered by Simple Taxonomy Ordering), and echo’ing the permalink. I see www.mylocalenv.dev/{cpt_slug}/{cpt_name}

    I disabled and deleted Simple Taxonomy Ordering and I see the same thing: www.mylocalenv.dev/{cpt_slug}/{cpt_name}

    Am I missing a polylang option somewhere? Do I need to tell Polylang that my CPT should be translatable and returning the language code for the permalink?

    Edit: I apologize I’ve never worked with Polylang. Thanks for working with me.

    • This reply was modified 9 years, 2 months ago by yikesitskevin.
    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    For the permalink settings, I have these three set:

    >The language is set from the directory name in pretty permalinks
    >Example: http://yikes.dev/en/my-post/

    >Remove /language/ in pretty permalinks
    >Example: http://yikes.dev/en/

    >The front page url contains the language code instead of the page name or page id
    >Example: http://yikes.dev/en/ instead of http://yikes.dev/en/home-page/

    Thread Starter brian1037

    (@brian1037)

    I’m so used to working with Polylang that it didn’t even occur to me to include my Polylang settings :p

    I’ve set two languages in Polylang, English being the first language, and French being the second one.

    Under URL Modifications in the Polylang settings, I’ve set “The language is set from the directory name in pretty permalink” on the left, and “Remove /language/ in pretty permalinks” on the right. Lastly, the “The front page url contains the language code instead of the page name or page id” is checked. Nothing else under “URL modifications” is checked.

    Under Custom post types and Taxonomies in the Polylang settings, I’ve set it to translate the custom post type, and the taxonomies. (I suspect the issue is coming from here).

    Nothing is being synchronized by Polylang.

    And the WordPress permalink structure is set to /%category%/%postname%/.

    Thanks!

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Yup I found the relevant settings, and can confirm that Simple Taxonomy Ordering removes the /en/ language code from the permalink.

    Investigating now.

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hey Brian,

    Well, my conclusion is that our plugin will not work with Polylang. What’s happening is that Polylang creates its own taxonomies, and these taxonomies are defining what language the CPT/post is in. We’re altering the query that fetches these taxonomies (to order the results) and we’re looking for the ‘tax_position’ key. Polylang’s taxonomies do not have the tax_position key assigned to them, and are returning nothing, and then defaulting to the site’s default language.

    I’m still looking into possible solutions but I’m not very optimistic at the moment.

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    In terms of the second issue you posted, the plugin wipes the termmeta table when it’s deleted, so I’m not sure how that’s persisting. Can you show me how a use case to test for that?

    Thread Starter brian1037

    (@brian1037)

    Ah, that is disappointing to hear, but I understand. It’s too bad because Simple Taxonomy Ordering has the best UI for reordering terms. All the other plugins use a disgusting extra page to manage the order. I really liked this plugin.

    At this point I would be happy with any kind of solution that can undo what the plugin did to the database.

    I guess that I’ll have to resort to another plugin for this task. There are others that don’t conflict with Polylang… might be worth looking into how they do it :p Just food for thought.

    Thanks again for your time

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Yeah I’m disappointed too. Could you point me towards another one of the ordering plugins that works with Polylang?

    In terms of the database, can you check the {prefix}_termmeta table? The only thing we add to the database is records in the termmeta table with the meta_key 'tax_position'. If those records are deleted, I’m not sure how anything with our plugin would persist.

    Thread Starter brian1037

    (@brian1037)

    Okay so I’ve done a bit more digging and you’ll be relieved to hear that I don’t think issue #2 is related to your plugin anymore. It was kind of the perfect storm of errors the other day, and seeing how Simple Taxonomy Ordering was causing some Polylang issues, I concluded that the other Polylang issues were from the same source. Now I can’t seem to reproduce the issue #2 anymore.

    I can also confirm it’s cleaning up after itself in the termmeta table. My apologies for that.

    As for other term ordering plugins that work with Polylang, this is the one I know works well: https://en-ca.ww.wp.xz.cn/plugins/custom-taxonomy-order-ne/

    It has a less than desirable admin UI unfortunately. That’s why I went with Simple Taxonomy Ordering.

    Feel free to mark this topic as resolved. Thanks for your help.

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Cheers Brian.

    I’ll mark this ticket as resolved but I will comment back here if I can fix Simple Taxonomy Ordering.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Plugin completely breaks Polylang’ is closed to new replies.