• ResolvedPlugin Contributor Grégory Viguier

    (@greglone)


    Hello Chouby.

    In PLL_Filters::comments_clauses() you filter the comments by post language, assuming the post type is translated. But what if it is not?

    In my case, WooCommerce: the post type is “product”, and it supports comments (reviews). If I choose not to translate it (by not checking it in Polylang settings), no comments will be shown.

    Thanks o/

    https://ww.wp.xz.cn/plugins/polylang/

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

    (@chouby)

    Hi!

    Could you precise your needs? If I create a non-translated post type, the comments are displayed on the single post page but the recent comments widget will never display them. Is that your problem?

    Plugin Contributor Grégory Viguier

    (@greglone)

    Hi Chouby 🙂

    Sorry, I wasn’t precise enough indeed, my apology.
    They won’t be displayed in the administration area: in the comments section nor in the post edition meta box. All is fine in front-end.

    For example, in the post edition meta box, there’s this:
    $total = get_comments( array( 'post_id' => $post->ID, 'number' => 1, 'count' => true ) );
    And the resulting query is this:
    SELECT COUNT(*) FROM wp_4_comments LEFT JOIN wp_4_posts ON comment_post_ID = wp_4_posts.ID INNER JOIN wp_4_term_relationships AS pll_tr ON pll_tr.object_id = ID WHERE ( comment_approved = '0' OR comment_approved = '1' ) AND comment_post_ID = 13 AND wp_4_posts.post_type NOT IN ('shop_order','shop_order_refund') AND wp_4_posts.post_type <> 'shop_webhook' AND pll_tr.term_taxonomy_id = 11 ORDER BY comment_date_gmt DESC LIMIT 1
    Side note: it’s a multisite installation, WooCommerce adds it’s own stuff in the query but they don’t seem to be a problem.

    Here, Polylang shouldn’t add its clauses until I choose to translate the CPT.
    Once I choose to translate the CPT in Polylang settings, I give it a language term and all works just fine then.

    Plugin Author Chouby

    (@chouby)

    Hello Greg,

    On admin side, the filter should be controlled by the admin language filter in the admin bar menu. If you display all languages, you should see your comments.

    One way to override this comportment is to force the query var ‘lang’ for example to ‘all’ in your comment query. I guess that the filter ‘pre_get_comments’ can be used for this purpose.

    Plugin Contributor Grégory Viguier

    (@greglone)

    Thanks 🙂

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

The topic ‘Comments for non translated post types’ is closed to new replies.