I have a query which fetches English courses only. How can I fetch all the languages courses? I am using WooCommrce with LearnDash.

public static function list_courses() {
        global $post;
        $postid = $post->ID;
        query_posts( array( 'post_type' => 'sfwd-courses', 'posts_per_page' => - 1 ) );
        $courses = array();
        while ( have_posts() ) {
            $courses[ get_the_ID() ] = get_the_title();
        $post = get_post( $postid );

        return $courses;
  • I'd look to see where the other language courses are stored - are they also sfwd-courses type posts in wp_posts? How are the posts flagged as English, e.g. a post meta property? In that case I'd guess something is automatically adding a 'show English courses only' filter to post queries, so you'll have to work out where that's coming from and remove it. – Rup Sep 12 at 12:06
  • Or maybe the other language courses are in a different table e.g. if this a multisite with separate per-language sites. You'd then probably have to search all the sites and combine the results I'd guess, or rig up a mysql query as SQL that unions the tables - I'm not sure that can be done through WP_Query. – Rup Sep 12 at 12:07
  • It appears you're trying to use this against LearnDash and as far as I know there is no "multi-language" integrated settings for courses .. my assumption is you're using some other plugin for translation, and you should ask for support from them how to do the query – sMyles Sep 14 at 23:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.