Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created July 13, 2015 05:57
Show Gist options
  • Select an option

  • Save bappi-d-great/c7d2199312aed4e1b462 to your computer and use it in GitHub Desktop.

Select an option

Save bappi-d-great/c7d2199312aed4e1b462 to your computer and use it in GitHub Desktop.
Show all unit modules in single unit page
<!-- This code should be placed in single-unit.php of your child theme -->
<div class="custom_unit_details">
<?php
$unit_class = new Unit( get_the_ID() );
$unit_pagination = cp_unit_uses_new_pagination( get_the_ID() );
if ( $unit_pagination ) {
$unit_pages = coursepress_unit_pages( get_the_ID(), $unit_pagination );
} else {
$unit_pages = coursepress_unit_pages( get_the_ID() );
}
?>
<ul>
<?php
for ( $i = 1; $i <= $unit_pages; $i++ ) {
?>
<li class="course_structure_page_li <?php echo $existing_student ? 'single_column' : ''; ?>">
<?php
$pages_num = 1;
$page_title = $unit_class->get_unit_page_name( $i );
?>
<label for="page_<?php echo get_the_ID() . '_' . $i; ?>">
<?php
$title = '';
if ( $existing_student && $enable_links ) {
$p_title = isset( $page_title ) && $page_title !== '' ? $page_title : __( 'Untitled Page', 'cp' );
$title = '<a href="' . trailingslashit( $unit_permalink ) . trailingslashit( 'page' ) . trailingslashit( $i ) . '">' . $p_title . '</a>';
} else {
$title = isset( $page_title ) && $page_title !== '' ? $page_title : __( 'Untitled Page', 'cp' );
}
?>
<div class="tree-page-left">
<?php echo $title; ?>
</div>
<div class="tree-page-right">
<?php
if ( isset( $preview_page[ get_the_ID() . '_' . $i ] ) && $preview_page[ get_the_ID() . '_' . $i ] == 'on' && $unit_permalink && !$existing_student ) {
?>
<a href="<?php echo $unit_permalink; ?>page/<?php echo $i; ?>?try" class="preview_option"><?php echo $free_text; ?></a>
<?php } ?>
</div>
</label>
<?php ?>
</li>
<?php
}//page visible
?>
</ul>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment