Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter karimit

    (@karimit)

    I just added the following action to functions.php, and Problem Solved:

    function update_post_language( $post_id ) {
    	$post_type = get_post_type($post_id);
    	if ($post_type == 'dwqa-question' || $post_type == 'dwqa-answer') {
    		$term = term_exists('ar', 'language');
    		if ($term !== 0 && $term !== null) {
    			wp_set_post_terms( $post_id, array ('ar'), 'language', true );
    		}
    	}
    }
    add_action( 'save_post', 'update_post_language' );

    Thanks again 🙂

    Thread Starter karimit

    (@karimit)

    I removed the filter and de-activated the language and translation management for my custom post types in Polylang settings (all check boxes for cpt’s are unchecked) and still Polylang filters the posts.
    Is there any other reason why this is happening, maybe some settings I must check?
    I am really sorry if I’m wasting your time, but i tried for too long to solve this on my own and I just couldn’t.

    Thread Starter karimit

    (@karimit)

    Hi Chouby,
    Thanks for your response.
    The problem was not introduced by the pll_get_post_types. I just added this filter to try change the language of a cpt from the admin screen to see if that solves the problem, and it does.
    The problem is always there whether the filter exists or not (unless if I manually change the language from the admin screen as I said) because Polylang always adds this little condition to the query :
    pll_tr.term_taxonomy_id = 4
    where 4 is the id of the term with value of “ar”.
    I hope I explained the issue well.
    Thanks again, waiting for your response 🙂

    Thread Starter karimit

    (@karimit)

    Thanks for your response. Actually I got it to work by choosing the “Use Disqus Comments on: only with blog posts with close comments” option in Disqus settings. Of course the question page comments should be open.
    Unfortunately, I ran into another problem. Visitors (not logged in users)can’t see comments on questions and answers. Only logged in users can. When the current user is a visitor, have_comments() always returns false. I found that the query (I echoed the $query varibale in wp-includes/comment.php) has an extra join that is causing the problem.
    Here is the query:
    SELECT * FROM wp_comments JOIN wp_posts ON wp_posts.ID = wp_comments.comment_post_ID INNER JOIN wp_term_relationships AS pll_tr ON pll_tr.object_id = ID WHERE comment_approved = '1' AND comment_post_ID = 76 AND pll_tr.term_taxonomy_id IN (2) ORDER BY comment_date_gmt ASC
    This part: INNER JOIN wp_term_relationships AS pll_tr ON pll_tr.object_id = ID is causing the problem. I tried this with a different site and its working perfectly, and this extra join was not there. I understand that this probably has nothing to do with the DW plugin. I just felt like sharing my problem :).
    Thanks anyway.

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