[Resolved] Override Settings

Home Forums Support [Resolved] Override Settings

Home Forums Support Override Settings

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #109651
    Mouring Kolhoff

    Hi Tom,

    I have a site with several post types, the public can add content to them via a frontend, so no access to the backend.

    Depending on the posttype I would like to show either no sidebars, one sidebar or two sidebar.

    For me to go into every entry to set the settings according to that posttype after some added data is a bit of a headache. Is there a way to set on a post type basis the layout required.

    #109673
    Tom
    Lead Developer
    Lead Developer

    Absolutely, we can set the page layout using a function and a filter, as seen in some examples here: http://generatepress.com/knowledgebase/choosing-sidebar-layouts/

    For you, 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 )
    {
     	// Get post type
     	$type = get_post_type();
    
     	// If our post type is named "my_post_type", set the sidebar
     	if ( 'my_post_type' == $type )
     	 	return 'both-left';
    
     	// If our post type is named "recipes", set the sidebar
     	if ( 'recipes' == $type )
     	 	return 'left-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }

    How to add PHP: http://generatepress.com/knowledgebase/adding-php-functions/

    Hope this helps ๐Ÿ™‚

    #110298
    Mouring Kolhoff

    Thanks Tom,

    This is working 100%

    Keep up the good work

    #110391
    Tom
    Lead Developer
    Lead Developer

    Thanks! ๐Ÿ™‚

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