Archived topic
Sidebar layout not work
10 replies · Started by Radek on June 27, 2015
Hi Tom, any way how to get GP sidebar layout + footer widget work with custom post types ?
For understanding if I choose "Content without sidebars" there is still sidebar at post frontend, but under content as You can see: http://test.erenza.net/?post_type=wpcm_match&p=132
Plugin author describe some solution here:
https://wpclubmanager.com/docs/themeing/#document-8
but I'm not so good with hooks...
so if You got some better solution for me ;)
thanx a lot
Radek
We have a pretty awesome filter that allows you to set the sidebar layout for custom areas: generatepress.com/knowledgebase/choosing-sidebar-layouts/#sidebar-filter
In this case, you could do something like this:
add_filter( 'generate_sidebar_layout','generate_custom_post_type_sidebar_layout' );
function generate_custom_post_type_sidebar_layout( $layout )
{
// Set the sidebar
if ( 'wpcm_match' == get_post_type() )
return 'left-sidebar';
// Or else, set the regular layout
return $layout;
}
sorry for stupid question, but where can I use this code ? functions.php or some child theme file ?
thanx
Any of the options on this page will work: http://generatepress.com/knowledgebase/adding-php-functions/
doesnt work (child theme functions.php method).
maybe because there is this file: wp-club-manager/templates/single-match.php with this code:
<?php
/**
* The Template for displaying all single matches.
*
* Override this template by copying it to yourtheme/wpclubmanager/single-match.php
*
* @author ClubPress
* @package WPClubManager/Templates
* @version 1.0.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
get_header(); ?>
<?php
/**
* wpclubmanager_before_main_content hook
*
* @hooked wpclubmanager_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked wpclubmanager_breadcrumb - 20
*/
do_action('wpclubmanager_before_main_content');
?>
<?php while ( have_posts() ) : the_post(); ?>
<?php wpclubmanager_get_template_part( 'content', 'single-match' ); ?>
<?php endwhile; // end of the loop. ?>
<?php
/**
* wpclubmanager_after_main_content hook
*
* @hooked wpclubmanager_output_content_wrapper_end - 10 (outputs closing divs for the content)
*/
do_action('wpclubmanager_after_main_content');
?>
<?php
/**
* wpclubmanager_sidebar hook
*
* @hooked wpclubmanager_get_sidebar - 10
*/
do_action('wpclubmanager_sidebar');
?>
<?php get_footer(); ?>
That would do it.
Try adding this:
add_action('wpclubmanager_sidebar','generate_contruct_sidebars');
still the same :(
if I commented:
<?php
/**
* wpclubmanager_sidebar hook
*
* @hooked wpclubmanager_get_sidebar - 10
*
* do_action('wpclubmanager_sidebar');
*/
?>
sidebar is gone, but thats not clean solution for me :)
This URL doesn't seem to be working for me: http://test.erenza.net/?post_type=wpcm_match&p=132
Can you double-check it and let me know? :)
it works for me, but its already OK because I did workaround using page template from GP to plugin file single-match.php
Yes, not comfortable solution, but if Im not good with programming, filters and hooks ;)
Weird - it's just a 404 page for me.
Either way, glad you found a solution :)
