Php 查询以从Wordpress中的Learndash获取所有注册课程

Php 查询以从Wordpress中的Learndash获取所有注册课程,php,wordpress,Php,Wordpress,我在WordPress上有一个learndash网站,里面有很多课程。我想向用户显示无序列表中的所有注册课程。我有一份清单,上面列出了所有课程,但没有列出当前注册的课程 参数中的mycourses=>true无效。获取所有课程的代码: $args= array('post_type' => 'sfwd-courses', 'post_status' => 'publish', 'order' => 'ASC', 'orderby' => 'ID', 'mycourses'

我在WordPress上有一个learndash网站,里面有很多课程。我想向用户显示
无序列表中的所有注册课程。我有一份清单,上面列出了所有课程,但没有列出当前注册的课程

参数中的
mycourses=>true
无效。获取所有课程的代码:

$args= array('post_type' => 'sfwd-courses',
'post_status' => 'publish',
'order' => 'ASC',
'orderby' => 'ID',
'mycourses' => 'true'
);
                        
$loop = new WP_Query( $args );
                        
while ( $loop->have_posts() ) : $loop->the_post();
    echo the_title();
endwhile;
我不喜欢使用默认的短代码


我不明白我怎么能把它和注册部分联系起来。我希望有经验的人能帮上忙。

我在wordexpress中没有经验,但你可以看看这个链接,它可能会有帮助:

好的,这是一个需要解决的问题,我确信有更好的方法来解决,但我找到了查询所有注册类的解决方案。下面是一个函数,用于为此创建一个短代码:

function enrolled_classes(){
    $user_id = get_current_user_id();
    $courses = learndash_user_get_enrolled_courses( $user_id, array(), true );
    $args = array(  
        'post_type' => array('sfwd-courses'),
        'post_status' => 'publish',
        'posts_per_page' => -1, 
        'orderby' => 'date', 
        'order' => 'asc', 
        'post__in'      =>  $courses,
    );
    $enrolled = new WP_Query( $args );
    if ( $enrolled->have_posts() ) {
        while ( $enrolled->have_posts() ) {
            $enrolled->the_post(); ?> 
            <?php get_template_part('templates/class-thumb-loop'); ?>   
        <?php }
    } else {
        // no posts found
        echo 'no posts found';
    }
    /* Restore original Post Data */
    wp_reset_postdata(); ?>
    <?php
}
add_shortcode('enrolled', 'enrolled_classes');
函数注册\u类(){
$user\u id=get\u current\u user\u id();
$courses=learndash\u user\u get\u registered\u courses($user\u id,array(),true);
$args=数组(
'post_type'=>数组('sfwd-courses'),
“发布状态”=>“发布”,
“每页帖子数”=>-1,
'orderby'=>'date',
“订单”=>“asc”,
“post_uuin”=>$courses,
);
$Registered=新的WP_查询($args);
如果($已注册->已发布帖子()){
而($Registered->have_posts()){
$Registered->the_post();?>