Support » Plugin: Polylang » SQL query for a italian post?

  • zearth


    Hi I can’t see in any post here on how to call a Post with Italian, Spanish or English translation. Below is a code that I put on my custom plugin but it calls all languages and translation. How can I specify it to call Italian, English or Spanish?

    $sql="SELECT ID,post_excerpt FROM wp_posts WHERE post_status = 'publish' AND post_type = 'postitem' ORDER BY post_date DESC";
    $aitem = array();
    $posts = $wpdb->get_results($sql);
    foreach ($posts as $post){
    $aitem[$post->ID] = $post->post_excerpt;

    thanks TIA

Viewing 1 replies (of 1 total)
  • Plugin Author Chouby


    Do you really need to use a sql query? You can use the get_posts function. For example:

    $posts = get_posts(array(
    	'numberposts' => -1,
    	'nopaging'    => true,
    	'post_type'   => 'postitem',
    	'post_status' => 'publish',
    	'lang'        => 'it',
Viewing 1 replies (of 1 total)
  • The topic ‘SQL query for a italian post?’ is closed to new replies.