[CoursePress Pro] Coursepress Pro. Showing Discussion Function On Dedicated Page

Since the discussion function is a discussion about the course, as apposed to the unit - it makes sense for us to display this discussion function on it's own stand alone page, and opposed to being a tab in the dashboard. I looked for a shortcode to display the course discussion on a page but did not find this.
Is there a function or shortcode I can create to display (just) the discussion for a course on it's own page?
Thanks.

  • Adam Czajczyk

    Hello Deryk

    I hope you're well today and thank you for your question!

    There's no shortcode/template tag for that and it would require some additional development.

    It could be achieved on a page template level though so you could create a dedicated page and a custom page template for it.

    Basically: courses and discussions are custom posts and actual "statements/posts" in a discussion are regular comments to "discussion" post type.

    Therefore, knowing course post ID you can use regular WP query to query associated posts of "discussion" type (to fetch discussions for this course)

    <?php
    			$page = ( isset( $wp->query_vars['paged'] ) ) ? $wp->query_vars['paged'] : 1;
    			$query_args = array(
    				'order' => 'DESC',
    				'post_type' => 'discussions',
    				'post_status' => 'publish',
    				'meta_key' => 'course_id',
    				'meta_value' => $course_id,
    				'paged' => $page,
    			);
    
    			query_posts( $query_args );
    ?>

    In the code above $course_id should have value of post ID of the course. After that query should come a regular WP loop. That loop would list all the discussions for this course. If you also include displaying comments in that loop - those comments would give you a full discussion view.

    Please note: that would require creating custom page template and would go into a custom development area so if you need help in coding it, please consider posting a job query on our "Jobs & Pros" job board (please note: no WPMU DEV staff involved!) here:

    https://premium.wpmudev.org/wordpress-development/

    However, if you feel like giving it a try by yourself and you have some additional question, let me know and I'll be happy to assist.

    Kind regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.