• Hi,

    Hoping somebody can help me. I’m currently trying to set up a Twenty Eleven child theme, and have added the sidebar to single pages. However I’m also posting photo galleries using Custom Post Types, and want those pages to take up the full width of the page (yes, like the one on Ma.tt!).

    I can get the category page to not display the sidebar, I can get the individual image pages to not display the sidebar – but I cannot, cannot, CANNOT get the main gallery post pages to not display the sidebar. Unless I remove the ‘get_sidebar’ call from the single post template, at which point it disappears from the gallery post too. I do want to keep the sidebar on single posts if I can – just not gallery and image posts.

    I’ve tried setting up CSS code to hide the sidebar on these pages. I’ve tried removing the get_sidebar call from everywhere I can get away with. I’ve tried conditional calls, which I think might be the solution but I can’t find the right one to stick. I’ve even tried creating a single-gallery.php template with the sidebar call removed, in the hope WP will call that before the single.php template on those pages – but I just cannot get the sidebar to budge! What am I doing wrong?!

    Further to this, I’d also appreciate some advice on how to move the content in these pages back over to the centre, as even those not showing the sidebar are rigidly clinging to the left. I suspect the two issues may be connected (ie. I think the sidebar may only be ‘hidden’ on these pages, not removed completely).

    Once again, any help anyone can offer me would be very much appreciated. ??

Viewing 1 replies (of 1 total)
  • Hi flyingnelly,

    I’m not sure if you’ve fixed this or not, but I was running into a similar issue and managed to find a solution. Working within the Twenty Eleven framework (such as when one is building a child theme), to condition certain elements (like a sidebar) when a single post is displayed, you must use the get_post_format() function.

    As an example, a solution to your situation would be to edit line 32 of single.php to read:

    <?php if ( get_post_format() != 'gallery' ) get_sidebar(); ?>

    I hope this helps you (and anyone else who may be searching for such a solution!

Viewing 1 replies (of 1 total)
  • The topic ‘[Twenty Eleven] Override single page template for custom post types’ is closed to new replies.