[Support request] Sidebar not showing on CPT

Home Forums Support [Support request] Sidebar not showing on CPT

Home Forums Support Sidebar not showing on CPT

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1449722
    Matthew

    Hi,

    I may have missed post on this already but didn’t see one in the search.

    I have a CPT (wpfc_sermon) generated by a third-party module (Sermon Manager – https://en-gb.wordpress.org/plugins/sermon-manager-for-wordpress/).

    I have managed to integrate it into GP using module provided filters and GP provided filters so that it displays Archive and Single as a GP Archive & Single. However, I cannot get a sidebar to display on Archive page or Single posts, and I’m not sure why.

    Sidebars work on normal posts, just not on this CPT.

    The code for integration is below, do you see anything obvious.

    add_filter( 'generate_blog_columns', function ( $columns ) {
        if ( is_post_type_archive( 'wpfc_sermon' ) ) {
            return true;
    	}
        return $columns;
    });
    
    add_filter( 'generate_sidebar_layout', function( $layout ) {
        // If we are viewing search results, set the sidebar
        if ( is_post_type_archive( 'wpfc_sermon' ) || is_page_template( 'content-sermon-single.php' ) || get_post_type() ==='wpfc_sermon' ) {
            return 'right-sidebar';
        }
    
        // Or else, set the regular layout
        return $layout;
     } );
    
    add_filter( 'sm_templates_wrapper_start' , function ($content) {
        ob_start();
    ?>
    	<div id="primary" <?php generate_do_element_classes( 'content' ); ?>>
    		<main id="main" <?php generate_do_element_classes( 'main' ); ?>>
    <?php 
        do_action( 'generate_before_main_content' );
    	return ob_get_clean();
    });
    
    add_filter( 'sm_templates_wrapper_end' , function ($content) {
        ob_start();
        do_action( 'generate_after_main_content' );
    ?>
    	</main><!-- #main -->
    	</div>
    <?php 
        do_action( 'generate_after_primary_content_area' );
        generate_construct_sidebars();
    
        return ob_get_clean();
    });
    #1449724
    Matthew

    Sorry, forgot to add the generate_get_layout() does return ‘right-sidebar’ for the CPT.

    #1450108
    Leo
    Staff
    Customer Support

    Hi there,

    Any chance you can link us to the site in question?

    You can use the private information field.

    Let me know 🙂

    #1451793
    Matthew

    I have attached those details.

    Just as an update if I removed the filters that wrap the CPT in GP container then the sidebar shows.

    #1452664
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Are you sure the template hooks are filters (add_filter) and not actions (add_action)? Do they have instructions on integrating themes with their plugin that we can check out?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.