Support » Plugin: Polylang » Polylang, ACF and direct db query

Viewing 1 replies (of 1 total)
  • Thread Starter frafor

    (@frafor)

    Got it!

    $language = pll_current_language();
    $rows = $wpdb->get_results($wpdb->prepare(
                "
                SELECT *
                FROM wp_posts
    			INNER JOIN wp_postmeta m1
    				ON (wp_posts.ID = m1.post_id)
    			INNER JOIN wp_term_relationships wtr
    				ON (wp_posts.ID = wtr.object_id)
    			INNER JOIN wp_term_taxonomy wtt
    				ON (wtr.term_taxonomy_id = wtt.term_taxonomy_id)
    			INNER JOIN wp_terms wt
    				ON (wt.term_id = wtt.term_id)
    			WHERE
    				wp_posts.post_type = 'attivita'
    			AND wp_posts.post_status = 'publish'
    			AND wtt.taxonomy = 'language'
    			AND wt.slug = %s
    			AND (m1.meta_key LIKE %s AND meta_value = %s)
                ",
    			$language,
    			'orario_%_giorno', // meta_name: $ParentName_$RowNumber_$ChildName
                $dayname // meta_value: 'type_3' for example
            ));
Viewing 1 replies (of 1 total)
  • The topic ‘Polylang, ACF and direct db query’ is closed to new replies.