Theme integration

Hi.

I am using CoursePress Pro on my new site and require some help with integration. If you look at a unit http://sugarnono.co.uk/newdev/courses/the-sugar-free-lifestyle-diet/units/introduction-to-the-course/#unit-page-1 you will see the content sits up and there is not the header image. To make a comparison please look at this page http://sugarnono.co.uk/newdev/blog/ You will see an image of a spoon with sugar and the title of the page.

How can I get this working like this with coursepress pro? I have had the same issue with BBpress threads.

Kind Regards

Stephen

ps support access is open

  • Adam Czajczyk

    Hello Stephen!

    Thank you for granting access.

    I checked your site and I can see that other CoursePress pages are being displayed fine (the course description page etc) but the "units" pages lack the header part.

    The general solution would be to create a custom page template that would be a copy of e.g. regular/default page template file of the current theme (which does seem to include the proper header). Since there's no way to assign a custom page template to the CoursePress pages via course settings this template would need to be named in a way following template hierarchy rules:

    https://developer.wordpress.org/themes/basics/template-hierarchy/

    The CoursePress unit is a custom post type of a name: "unit". The "single-unit.php" named custom page template file should do the job here.

    You mentioned before that you experienced the same issue with bbPress pages though. Could you please let me know how was it solved? The reason for both these issues seems to be similar so I think this could also be solved in a similar fashion if not by the custom page template.

    Best regards,
    Adam

  • Stephen

    Hi.
    Thank you for your reply. To solve the BBpress issue I did two things. I copied the single.php file and named it bbpress.php in my theme folder. This allowed the thread pages to load with the site header and design. How ever, I was still have issues with getting the threads to show so I decided to ditch BBpress and use your forums plugin, this being the second thing.

    Would you think if I created a file called single-unit.php in my themes folder using the content from the single.php file would work?

    I am not a coder but can follow simple instructions.

    Thanks

    Stephen

  • Stephen

    Thanks for your reply.

    I have tried to add the header code from the single.php file in my theme to single-unit.php in coursepress. Nothing changes.

    Below is the code for the single.php file. Are you able to see what I need to use to get it working?

    <?php
    get_header();
    $settings = crazyblog_opt();
    $single_setting = $settings;
    $post_meta = get_post_meta( get_the_ID(), 'crazyblog_post_meta', true );
    $object = get_queried_object_id();
    $meta = crazyblog_set( crazyblog_set( $post_meta, 'crazyblog_post_options' ), '0' );
    
    if ( crazyblog_set( $meta, 'post_title_section' ) == '' ) {
    	$show_banner = crazyblog_set( $settings, 'single_title_section' );
    	$bg = (crazyblog_set( $settings, 'single_title_section_bg' )) ? 'background:url(' . crazyblog_set( $settings, 'single_title_section_bg' ) . ')' : "";
    } else {
    	$show_banner = crazyblog_set( $meta, 'post_title_section' );
    	$bg = (crazyblog_set( $meta, 'title_section_bg' )) ? 'background:url(' . crazyblog_set( $meta, 'title_section_bg' ) . ')' : "";
    }
    
    if ( crazyblog_set( $meta, 'layout' ) == '' && crazyblog_set( $meta, 'layout' ) != 'full' ) {
    	$sidebar = (crazyblog_set( $settings, 'single_page_sidebar' )) ? crazyblog_set( $settings, 'single_page_sidebar' ) : "";
    	$layout = ($sidebar && crazyblog_set( $settings, 'single_sidebar_layout' )) ? crazyblog_set( $settings, 'single_sidebar_layout' ) : "";
    	$cols = ($layout != "full" && $sidebar ) ? "col-md-8" : 'col-md-12';
    } else {
    	$sidebar = (crazyblog_set( $meta, 'sidebar' )) ? crazyblog_set( $meta, 'sidebar' ) : "";
    	$layout = ($sidebar && crazyblog_set( $meta, 'layout' )) ? crazyblog_set( $meta, 'layout' ) : "";
    	$cols = ($layout != "full" && $sidebar ) ? "col-md-8" : 'col-md-12';
    }
    
    $no_image = "";
    $year = get_the_time( 'Y' );
    $month = get_the_time( 'm' );
    $day = get_the_time( 'd' );
    crazyblog_set_posts_views( get_the_ID() );
    crazyblog_View::get_instance()->crazyblog_enqueue_scripts( array( 'df-magnific' ) );
    ?>
    
    <?php if ( $show_banner ) : ?>
    	<div class="pagetop" style="<?php echo esc_attr( $bg ); ?>">
    		<div class="page-name">
    			<div class="container">
    				<span>
    					<?php echo esc_html( get_the_title( $object ) ); ?>
    				</span>
    				<?php echo crazyblog_get_breadcrumbs(); ?>
    			</div>
    		</div>
    	</div><!-- Page Top -->
    <?php endif; ?>
    
    <section>
        <div class="block">
            <div class="container">
                <div class="row">
    				<?php if ( is_active_sidebar( $sidebar ) && $layout == "left" ) : ?>
    					<aside class="col-md-4 column sidebar left-sidebar">
    						<?php dynamic_sidebar( $sidebar ); ?>
    					</aside>
    				<?php endif; ?>
    				<?php
    				if ( have_posts() ) : while ( have_posts() ) :
    						the_post();
    						$format = get_post_format( get_the_ID() );
    						if ( $format == '' ) {
    							$format = 'standard';
    						}
    						if ( $format == "video" ) {
    							include crazyblog_ROOT . "core/application/library/single/format-video.php";
    						} elseif ( $format == "audio" ) {
    							include crazyblog_ROOT . "core/application/library/single/format-audio.php";
    						} elseif ( $format == "gallery" ) {
    							include crazyblog_ROOT . "core/application/library/single/format-gallery.php";
    						} elseif ( $format == "quote" ) {
    							include crazyblog_ROOT . "core/application/library/single/format-quote.php";
    						} elseif ( $format == "link" ) {
    							include crazyblog_ROOT . "core/application/library/single/format-link.php";
    						} elseif ( $format == "image" ) {
    							include crazyblog_ROOT . "core/application/library/single/format-image.php";
    						} else {
    							include crazyblog_ROOT . "core/application/library/single/format-image.php";
    						}
    					endwhile;
    					wp_reset_postdata();
    				endif;
    				?>
    				<?php if ( is_active_sidebar( $sidebar ) && $layout == "right" ) : ?>
    					<aside class="col-md-4 column sidebar right-sidebar">
    						<?php dynamic_sidebar( $sidebar ); ?>
    					</aside>
    				<?php endif; ?>
                </div>
            </div>
        </div>
    </section>
    <?php crazyblog_View::get_instance()->crazyblog_enqueue_scripts( array( 'df-owl' ) ); ?>
    <?php
    $custom_script = 'jQuery(document).ready(function ($) {
            jQuery(".related-carousel").owlCarousel({
                autoplay: true,
                autoplayTimeout: 2500,
                smartSpeed: 2000,
                autoplayHoverPause: true,
                loop: false,
                dots: false,
                nav: true,
                margin: 30,
                mouseDrag: true,
                autoHeight: true,
                items: 2,
                responsive: {
                    1200: {items: 2},
                    980: {items: 2},
                    768: {items: 2},
                    480: {items: 2},
                    0: {items: 1}
                }
            });
            jQuery(".related-posts").removeClass("none");
        });';
    wp_add_inline_script( 'crazyblog_df-owl', $custom_script );
    ?>
    <?php get_footer(); ?>

    Thanks

  • Dimitris

    Hey there Stephen,

    hope you're doing good and don't mind chiming in! :slight_smile:

    I have tried to add the header code from the single.php file in my theme to single-unit.php in coursepress. Nothing changes.

    It truly seems that the following part doesn't display

    <?php if ( $show_banner ) : ?>
    	<div class="pagetop" style="<?php echo esc_attr( $bg ); ?>">
    		<div class="page-name">
    			<div class="container">
    				<span>
    					<?php echo esc_html( get_the_title( $object ) ); ?>
    				</span>
    				<?php echo crazyblog_get_breadcrumbs(); ?>
    			</div>
    		</div>
    	</div><!-- Page Top -->
    <?php endif; ?>

    Did you try to make the changes in /wp-content/plugins/coursepress/themes/coursepress/single-unit.php file?
    Could you please try to copy this new file to /wp-content/themes/YOUR_ACTIVE_(CHILD)THEME/single-unit.php and try again? And safely revert the plugins template file back to normal. :wink:

    If you already did so, then please provide us some FTP credentials in order to have a better look.
    As this is public forum, you must send us your details through our safe contact form https://premium.wpmudev.org/contact/ using this template:

    Subject: "Attn: Dimitris"
    -WordPress admin username
    -WordPress admin password
    -WordPress login url
    -FTP credentials (host/username/password)
    -link back to this thread for reference
    -any other relevant urls

    Select "I have a different question" for your topic - this and the subject line ensure that it gets assigned to me.

    Warm regards,
    Dimitris

  • Dimitris

    Hey there Stephen,

    in order to make this work with your theme, I had to make a change in page.php file.
    I noticed though, that you had an empty child-theme in place, so in order not to mess up with parent theme files, I activated it and added the /newdev/wp-content/themes/crazyblog-child/page.php file, hard-coding a background image for those pages (like a units page) which don't declare such an image (you may notice this default image set in "Page Top" area in this file).

    Hope that helps, please confirm to me that I didn't mess up anything else with this! :slight_smile:

    Warm regards,
    Dimitris

  • Dimitris

    Hey there Stephen,

    hope you're doing good today! :slight_smile:

    I was wondering if you would be kind enough to tell me how you fixed this?

    By using a page.php file in your child-theme in order to override any pages that were using this template. :wink:
    https://wphierarchy.com/
    In there, around line#10 we check if current view is the homepage, and the next if/else statement in line#11, tries to fetch background image set by theme settings. If a page, like a course unit page, doesn't have this setting, then we hard-code an image URL (line#21).

    I have noticed that on my recipe plugin I am using, if I go to a category the header image is missing. http://sugarnono.co.uk/newdev/recipe-category/free-recipes/

    This page was using a template from /newdev/wp-content/plugins/cooked/templates/archive-cp_recipe.php which included the default get_header() but not any theme specific headers.
    So, I went ahead and copied this file to your child-theme folder and I added right after the get_header() function the following from page.php template :wink:

    <div class="pagetop" style="background:url(http://sugarnono.co.uk/newdev/wp-content/uploads/2016/09/slide-1.jpg)">
    	<div class="page-name">
    		<div class="container">
    			<span><?php echo esc_html( get_the_title() ); ?></span>
    			<?php echo crazyblog_get_breadcrumbs(); ?>
    		</div>
    	</div>
    </div><!-- Page Top -->

    Hope that helps,
    Dimitris