Created
July 8, 2015 14:34
-
-
Save yojance/f758a879771c8aefc719 to your computer and use it in GitHub Desktop.
Random Courses file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
'post_type' => 'sfwd-courses', | |
'orderby' => 'rand', | |
'no_found_rows' => 1, | |
'posts_per_page'=> 2, | |
'author' => $post->post_author, // Needs the current Course Author ID | |
'post__not_in' => array( $post->ID ), // Needs the current Course ID | |
); | |
$author_random_courses = new WP_Query( $args ); | |
if( $author_random_courses->have_posts() ): while( $author_random_courses->have_posts() ): $author_random_courses->the_post(); ?> | |
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a> | |
<?php the_title(); ?> | |
<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>"><?php the_author_meta( 'display_name' ); ?></a> | |
<?php the_excerpt(); ?> | |
<a href="<?php echo post_permalink( $post->ID ); ?>" class="btn btn-lg">Watch Course</a> | |
<?php endwhile; endif; wp_reset_query(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment