Need Help Creating Correct Output for CoursePress

I am working with a theme called TA-Pluton (http://themeart.co/free-theme/ta-pluton/) to make it work with CoursePress. I would like to modify the home page template to output course information instead of portfolio information. However, I am doing something wrong and was hoping you could help. I have included the code that I want to modify.

If you can help, that would be greatly appreciated. If you can't, I was hoping you could at least point me in the right direction.

Thanks!

  • Visceral Concepts

    Ok, didn't realize I couldn't attach PHP files. The code that I specifically want to modify is below. Thanks!

    <!-- Start details for portfolio project -->
    			<div id="single-project">
    				<?php
    				// the query
    				$the_query = new WP_Query( array( 'post_type' => 'courses', 'posts_per_page' => -1 ) ); ?>
    
    				<?php if ( $the_query->have_posts() ) : ?>
    
    				<!-- the loop -->
    				<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    
    				<div id="slidingDiv<?php echo get_the_ID() ?>" class="toggleDiv row-fluid single-project">
    					<div class="span6">
    						<img src="<?php echo wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?>" alt="project" />
    					</div>
    					<div class="span6">
    						<div class="project-description">
    							<div class="project-title clearfix">
    								<h3><?php the_title(); ?></h3>
    								<span class="show_hide close">
    									<i class="icon-cancel"></i>
    								</span>
    							</div>
    							<div class="project-info">
    								<div><span><?php _e( 'Client', 'ta-pluton' ); ?></span><?php echo get_post_meta( $post->ID, '_cmb_clientname', true); ?></div>
    								<div><span><?php _e( 'Date', 'ta-pluton' ); ?></span><?php echo get_the_date(); ?></div>
    								<div><?php $tags = wp_get_post_terms( $post->ID, 'portfolio_tags', array( "fields" => "names" ) ); ?><span><?php _e( 'course-categories', 'ta-pluton' ); ?></span><?php echo implode( ' / ',$tags ); ?></div>
    								<div><span><?php _e( 'Link', 'ta-pluton' ); ?></span><?php echo get_post_meta( $post->ID, '_cmb_clienturl', true); ?></div>
    							</div>
    							<?php the_content(); ?>
    						</div>
    					</div>
    				</div>
    				<!-- End details for portfolio project -->
  • Bojan Radonic

    Hey there @Visceral Concepts, hope you're well today!

    The plugin uses a virtual page for courses page which is why you can't simply add that page as your home page.

    But you can create a real page and use any combination of the shortcodes that you'll find under the Shortcodes tab in CoursePress Pro > Settings. When done you can use that page as your home page where you'll have courses displayed.

    Try using the [course_list] shortcode first that you'll find almost at the bottom of the shortcodes page. Try using different available parameters to see what kind of layout you can build.

    If this is not what you want and you still want to use the code I'll include SLS (our coding experts) for their input on this :slight_smile:

    Please let me know.

    Best regards,
    Bojan

  • Visceral Concepts

    Ok, so I'm trying to get the output to show all the course information, including course overview, instructors, and the enroll link. However, I can not get the course information to display when I use what I find in the course overview template. What am I doing wrong? The code is below.

    <div id="slidingDiv<?php echo get_the_ID() ?>" class="toggleDiv row-fluid single-project">
    					<div class="span6">
    						<img src="<?php echo Course::get_course_thumbnail( $post->ID ); ?>" alt="course image">
    					</div>
    					<div class="span6">
    						<div class="project-description">
    							<div class="project-title clearfix">
    								<h3><?php the_title(); ?></h3>
    								<span class="show_hide close">
    									<i class="icon-cancel"></i>
    								</span>
    							</div>
    							<div class="project-info">
        <div class="entry-content-excerpt <?php echo ($course_media == '' ? 'entry-content-excerpt-right' : '' ); ?>">
    			<?php //the_excerpt();   ?>
                <div class="course-box">
    				<?php echo do_shortcode( '[course_dates show_alt_display="yes"]' ); //change to yes for 'Open-ended' ?>
    				<?php echo do_shortcode( '[course_enrollment_dates show_alt_display="no"]' ); //change to yes for 'Open-ended' ?>
    				<?php echo do_shortcode( '[course_class_size]' ); ?>
    				<?php echo do_shortcode( '[course_enrollment_type label="'.__('Who can Enroll: ', 'cp').'"]' ); ?>
    				<?php echo do_shortcode( '[course_language]' ); ?>
    				<?php echo do_shortcode( '[course_cost]' ); ?>
    
                </div><!--course-box-->
                <div class="quick-course-info">
    				<?php echo do_shortcode( '[course_join_button]' ); ?>
                </div>
            </div>
    							</div>
    							<?php the_content(); ?>
    						</div>
    					</div>
    				</div>
  • Jose

    Hey there,

    The problem seems to be that the flag 'in_the_loop' is not set when rendering the shortcode. Therefore, you need to ensure that the course ID is correctly set in the shortcode.

    This should work:

    <div class="course-box">
    <?php echo do_shortcode( '[course_summary course_id="' . $post->ID . '"]' );//Overview ?><?php echo do_shortcode( '[course_instructors course_id="' . $post->ID . '"]' );//Instructors ?>
    <?php echo do_shortcode( '[course_dates course_id="' . $post->ID . '" show_alt_display="yes"]' ); //change to yes for 'Open-ended' ?>
    <?php echo do_shortcode( '[course_enrollment_dates course_id="' . $post->ID . '" show_alt_display="no"]' ); //change to yes for 'Open-ended' ?>
    <?php echo do_shortcode( '[course_class_size]' ); ?>
    <?php echo do_shortcode( '[course_enrollment_type course_id="' . $post->ID . '" label="'.__('Who can Enroll: ', 'cp').'"]' ); ?>
    <?php echo do_shortcode( '[course_language course_id="' . $post->ID . '"]' ); ?>
    <?php echo do_shortcode( '[course_cost course_id="' . $post->ID . '"]' ); ?>
    
    </div><!--course-box-->
    <div class="quick-course-info">
    <?php echo do_shortcode( '[course_join_button course_id="' . $post->ID . '"]' ); ?>
    </div>

    Let me know how it works. :slight_smile:

    Cheers,
    Jose

  • Jose

    Actually, I didn't explain it well :slight_smile:

    The shortcodes were showing partially, not all of them were working properly (at least not in my install). The explicit course ID is needed in some of the shortcodes.

    Also, in my post above you can find the overview and instructors shortcodes added:

    <?php echo do_shortcode( '[course_summary course_id="' . $post->ID . '"]' );//Overview ?>
    <?php echo do_shortcode( '[course_instructors course_id="' . $post->ID . '"]' );//Instructors ?>

    The enroll button wasn't showing without the explicit course ID. It work fine using this:
    <?php echo do_shortcode( '[course_join_button course_id="' . $post->ID . '"]' ); ?>

    Let me know if I'm missing something here.

    Cheers!
    Jose

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.