Skip to content

Commit

Permalink
= 4.2.6.5 =
Browse files Browse the repository at this point in the history
~ Fixed: preview single course.
  • Loading branch information
tungnxt89 committed Apr 6, 2024
1 parent d3caeac commit f6c3e4c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions templates/single-course.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,19 @@
do_action( 'learn-press/before-main-content-single-course' );

// WP 6.4 with Block theme can't detect single course, so code while ( have_posts() ) not run.
$args = array(
'name' => get_query_var( LP_COURSE_CPT ),
'post_type' => LP_COURSE_CPT,
'posts_per_page' => 1,
$args = array(
'name' => get_query_var( LP_COURSE_CPT ),
'post_type' => LP_COURSE_CPT,
'numberposts' => 1,
);

// Fix preview course
if ( isset( $_REQUEST['preview'] ) && isset( $_REQUEST['p'] ) ) {
unset( $args['name'] );
$args['include'] = [ (int) $_REQUEST['p'] ];
$args['post_status'] = 'any';
}

$posts = get_posts( $args );
$post = $posts[0] ?? 0;

Expand Down

0 comments on commit f6c3e4c

Please sign in to comment.