Skip to content

Instantly share code, notes, and snippets.

@pasadamedia
Created January 28, 2015 06:02
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pasadamedia/fa0a13cfa43c69f7a51f to your computer and use it in GitHub Desktop.
Save pasadamedia/fa0a13cfa43c69f7a51f to your computer and use it in GitHub Desktop.
Display WooThemes Sensei featured courses in a page template
/**
* Display Sensei Featured Courses.
*
* Displays a list of featured courses.
*
* @since 1.0.0
* @return void
* @uses WP_Query()
* @link http://www.woothemes.com/sensei/
* @author WooThemes
*/
function pasada_display_featured_courses() {
if ( class_exists( 'Woothemes_Sensei' ) ) {
global $woothemes_sensei;
?>
<section class="content-section featured-courses clearfix">
<?php
$args = array(
'post_type' => 'course',
'meta_key' => '_course_featured',
'meta_value' => 'featured',
'posts_per_page' => apply_filters( 'woo_sensei_featured_courses_number', 3 ),
);
$courses = get_posts( $args );
?>
<?php if ( isset( $courses ) && 0 < $courses ) : ?>
<header class="section-title">
<h2 class="section-title-heading">Featured Courses</h2>
<p class="section-title-description">Learn practical skills and in-depth theory from experienced practitioners.</p>
</header>
<?php $count = 0; foreach ( $courses as $course ) : $count++;
$class = ''; if ( $count == 1 ) : $class = 'first'; endif; ?>
<article class="featured-course one-third <?php echo $class; ?>">
<?php if ( has_post_thumbnail( $course->ID ) ) : ?>
<div>
<?php echo esc_attr( $woothemes_sensei->frontend->sensei_course_image( $course->ID, 390, 260 ) ); ?>
</div>
<?php endif; ?>
<header>
<h3><a href="<?php echo esc_url( get_permalink( $course->ID ) ); ?>"><?php echo esc_attr( get_the_title( $course->ID ) ); ?></a></h3>
</header>
<section class="featured-course-entry">
<?php if ( isset( $course->post_excerpt ) && '' != $course->post_excerpt ) : ?>
<p><?php echo esc_attr( $course->post_excerpt ); ?></p>
<?php endif; ?>
<!-- <p><a class="button" href="<?php /*echo esc_url( get_permalink( $course->ID ) ); */?>">View Course</a></p>
--> </section>
<div></div>
</article>
<?php endforeach; ?>
<p class="clear"><a class="button" href="/courses-overview/" title="View the complete course calendar">View all courses</a></p>
<?php endif; ?>
</section>
<?php
wp_reset_postdata();
}
}
add_action( 'genesis_before_content', 'pasada_display_featured_courses', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment