Thread Starter
Que42
(@que42)
I have read that creating a functions.php for my child theme (twentytwelve-child) that reads “Something like this” would solve the problem.
add_filter(‘body_class’,’twentytwelvechild_body_classes’,20);
function twentytwelvechild_body_classes( $classes ) {
if ( is_category() || is_single() )
$classes[] = ‘full-width’;
return $classes;
}
However all it gets me is this across the top of my page.
add_filter(‘body_class’,’twentytwelvechild_body_classes’,20); function twentytwelvechild_body_classes( $classes ) { if ( is_category() || is_single() ) $classes[] = ‘full-width’; return $classes; }
Is there something else I need to include in this file? Or is the wording/coding not exactly like it should be as I suspect from the “Something like this” My knowledge of html is pretty decent, css I’m just learning and php very little. Any help would be a God send as I’m literally pulling out my hair over this.
[No bumping. If it’s that urgent, consider hiring someone.]
Bumping is not allowed.
http://codex.wordpress.org/Forum_Welcome#No_Bumping
You can use condition tag is_single().
Rough idea will be:
if !(is_single()) {
get_sidebar();
}
Thread Starter
Que42
(@que42)
Sorry about the bump. I saw it done on another thread, and blatantly as in “bump” so didn’t think it bad.
Would it be possible to be a little more specific on the
if !(is_single()) {
get_sidebar();
}
My knowledge of php is very limited. Is this exactly what I plug in and where should I put it. And I’m assuming you’re talking about the single.php file. Fortunately this is the only php issue I have. The rest is all css and there has been much written about it.
Make backup of your single.php and try implementing my suggestion.
Wait.
I checked Twenty Twelve’s source code, and I think you need to make following changes.
Edit sidebar.php.
Replace line 13, that is:
<?php if ( is_active_sidebar( 'sidebar-1' ) ) : ?>
with follwing:
<?php if (( is_active_sidebar( 'sidebar-1' )) || !(is_single) ) : ?>
Thread Starter
Que42
(@que42)
Hey Aditya many, many, many thanks for the help but no dice. It may well have gotten rid of the sidebar but that had already been done on single.php by removing
<?php get_sidebar(); ?>
The question now is how to get the content to go full width. Right now it keeps the content on the left 2/3 of the page as if the sidebar was still there. Here is the single.php code from twenty twelve so you don’t have to look it up. (minus the <?php get_sidebar(); ?>)
<?php
/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Twenty_Twelve
* @since Twenty Twelve 1.0
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<nav class="nav-single">
<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentytwelve' ); ?></h3>
<span class="nav-previous"><?php previous_post_link( '%link', '<span class="meta-nav">' . _x( '←', 'Previous post link', 'twentytwelve' ) . '</span> %title' ); ?></span>
<span class="nav-next"><?php next_post_link( '%link', '%title <span class="meta-nav">' . _x( '→', 'Next post link', 'twentytwelve' ) . '</span>' ); ?></span>
</nav><!-- .nav-single -->
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
I already mentioned the easiest solution.
Remove all your customization and read my last reply.
Thread Starter
Que42
(@que42)
Hmmmmmmmm Sorry but didn’t work for me. Don’t know what I did wrong. Returned the single.php to original via backup that included the <?php get_sidebar(); ?>
And then edited the sidebar.php as per instructed with the <?php if ( is_active_sidebar( ‘sidebar-1’ ) ) : ?> and the single post pages still show the sidebar.
Glad this is only php issue. When you’ve never done php it looks like a foreign language lol.
Okay then.
Open single.php.
Replace line 12, that says:
<div id="primary" class="site-content">
and replace with :
<div id="primary">
And let me know how it goes.
Thread Starter
Que42
(@que42)
Aditya you are thee ******* MAN! Have been pulling me freaking hair out over this for two days.
For those that find this searching and I know there will be plenty as I’ve seen a lot of posts via searching on this very subject Aditya’s last post did the trick. Made the content go full width on post pages.
BUT it left the sidebar which showed under the content. To remove the sidebar completely you must do the for mentioned as in this example
in single.php at bottom you will find this
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
remove the <?php get_sidebar(); ?> so that you have this
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Once again many thanks to Aditya who took the time to help out a poor nob.
You are sharing wrong information.
You said to edit “sidebar.php”, but in your case you edited single.php.
Thread Starter
Que42
(@que42)
heheheh already caught it and edited the post before to late.