SQL query for a italian post? (2 posts)

  1. zearth
    Posted 2 years ago #

    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


  2. Chouby
    Plugin Author

    Posted 2 years ago #

    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',

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Polylang
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic