Title: Setting default language for custom post types
Last modified: August 21, 2016

---

# Setting default language for custom post types

 *  Resolved [karimit](https://wordpress.org/support/users/karimit/)
 * (@karimit)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/setting-default-language-for-custom-post-types/)
 * Hi,
    I’m trying to set a default language of posts created by a plugin for questions
   and answers that I use. The only language installed in my site is Arabic. And
   since questions and answers has no defined language, I can’t get comments related
   to them because Polylang tries to filter results by language. When I registered
   the question and answer post types using the pll_get_post_types filter I was 
   able to set their language through the admin screen. But now I’m searching for
   a way to set the language automatically for new posts maybe with an action, or
   disable filtering by language for these tow custom post types.
 * Thanks in advance.
 * [http://wordpress.org/plugins/polylang/](http://wordpress.org/plugins/polylang/)

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

 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/setting-default-language-for-custom-post-types/#post-4353335)
 * > disable filtering by language for these tow custom post types
 *  That’s the easiest. You just have to deactivate the language and translation
   management for these custom post types in Polylang settings. Depending on the
   way you wrote your `pll_get_post_types` filter, your post types may not appear,
   so if they don’t try removing your filter.
 *  Thread Starter [karimit](https://wordpress.org/support/users/karimit/)
 * (@karimit)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/setting-default-language-for-custom-post-types/#post-4353339)
 * 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 🙂
 *  Plugin Author [Chouby](https://wordpress.org/support/users/chouby/)
 * (@chouby)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/setting-default-language-for-custom-post-types/#post-4353340)
 * If you don’t use the filter and you de-activate the language and translation 
   management for your custom post type in Polylang settings then the Polylang shoud
   not filter your custom post type (and so not add this `pll_tr.term_taxonomy_id
   = 4` in query)
 *  Thread Starter [karimit](https://wordpress.org/support/users/karimit/)
 * (@karimit)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/setting-default-language-for-custom-post-types/#post-4353342)
 * 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](https://wordpress.org/support/users/karimit/)
 * (@karimit)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/setting-default-language-for-custom-post-types/#post-4353397)
 * 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 🙂

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

The topic ‘Setting default language for custom post types’ is closed to new replies.

 * ![](https://ps.w.org/polylang/assets/icon-256x256.png?rev=3433336)
 * [Polylang](https://wordpress.org/plugins/polylang/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/polylang/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/polylang/)
 * [Active Topics](https://wordpress.org/support/plugin/polylang/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/polylang/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/polylang/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [karimit](https://wordpress.org/support/users/karimit/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/setting-default-language-for-custom-post-types/#post-4353397)
 * Status: resolved