Advertisement
Guest User

Revised single-unit.php template (for Genesis)

a guest
Feb 19th, 2015
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.82 KB | None | 0 0
  1. <?php
  2.  
  3. //* Replace Genesis loop
  4. remove_action( 'genesis_loop', 'genesis_do_loop' );            
  5. add_action( 'genesis_loop', 'pactems_course_single_unit' );
  6. function pactems_course_single_unit(){
  7.  
  8.         global $coursepress, $wp, $wp_query;
  9.  
  10.         $course_id = do_shortcode('[get_parent_course_id]');
  11.  
  12.         add_thickbox();
  13.  
  14.         $paged = ! empty( $wp->query_vars['paged'] ) ? absint($wp->query_vars['paged']) : 1;
  15.         //redirect to the parent course page if not enrolled or not preview unit/page
  16.         while ( have_posts() ) : the_post();
  17.                 $coursepress->check_access($course_id, get_the_ID());
  18.         endwhile;
  19.  
  20.         $post = $unit->details; ?>
  21.        
  22.        
  23.         <div id="primary" class="content-area">
  24.                 <main id="main" class="site-main" role="main">
  25.                         <?php while ( have_posts() ) : the_post(); ?>
  26.                                 <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  27.                                         <header class="entry-header">
  28.                                                 <h3 class="entry-title"><?php echo do_shortcode('[course_title course_id="' . $course_id . '"]'); ?></h3>
  29.                                                 <?php
  30.                                                 echo do_shortcode('[course_unit_details unit_id="' . get_the_ID() . '" field="parent_course"]');
  31.                                                 ?>
  32.                                         </header><!-- .entry-header -->
  33.                                         <div class="instructors-content"></div>
  34.                                         <?php
  35.                                         echo do_shortcode('[course_unit_archive_submenu course_id="' . $course_id . '"]');
  36.                                         ?>
  37.  
  38.                                         <div class="clearfix"></div>
  39.  
  40.                                         <?php echo do_shortcode('[course_unit_details unit_id="' . $course_id . '" field="unit_page_title" unit_title="'.get_the_title().'"]'); ?>
  41.  
  42.                                         <div class="entry-content">
  43.                                                 <?php
  44.                                                 if ( $paged == 1 ) { //Unit introduction will be shown only on the first page
  45.                                                         the_content();
  46.                                                 }
  47.                                                 ?>
  48.                                         </div>
  49.                                         <?php Unit_Module::get_modules_front($unit->details->$course_id);?>
  50.                                 </article>
  51.                         <?php endwhile; // end of the loop. ?>
  52.                 </main><!-- #main -->
  53.        </div><!-- #primary -->
  54.  
  55. <?php }
  56.  
  57. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement