Home > Development, WordPress > Remove WordPress iNove theme sidebar using custom fields

Remove WordPress iNove theme sidebar using custom fields

I’m using WordPress iNove theme v.1.4.6 and i needed a way to hide the sidebar for a specific post so i dove in the iNove theme code and figured out how to do this with the minimum changes to the original theme code.

First open the iNove theme ‘header.php’ file using your favorite editor, usually found at <wp install folder>/wp-content/themes/inove/header.php.

Now look for this piece of code (starting from the top of the file):

... some code ...
			$feed = 'http://' . $options['feed_url'];
		}
	} else {
		$feed = get_bloginfo('rss2_url');
	}
?>


Now append at the end of that code the following snippet:

<?php
    global $wp_query;
    if( get_post_meta( $wp_query->post->ID, 'nosidebar', 'true') ){
        $inove_nosidebar = true;
    }
?>

You should get some thing like this:

... some code ...
			$feed = 'http://' . $options['feed_url'];
		}
	} else {
		$feed = get_bloginfo('rss2_url');
	}
?>

<?php
    global $wp_query;
    if( get_post_meta( $wp_query->post->ID, '', 'true') ){
        $inove_nosidebar = true;
    }
?>

<html xmlns="http://www.w3.org/1999/xhtml">

Now when you need to disable the sidebar in a post you simply add a new ‘Custom Field’ named ‘nosidebar’ and set it’s value to ‘true’ like you see in the figure.

Wordpress setting 'nosidebar' custom field

Et voilà, all done!

  1. March 6th, 2010 at 20:29 | #1

    Thanks a lot man, this was REALLY helpful. To think, after so much splicing and cutting and butchering, that there was such a simple solution all along! C’est la vie.

  2. Sandy
    March 24th, 2010 at 15:12 | #2

    I tried this and triple checked every detail but as soon as I add this to my header.php it removes sidebar from every page. Not just the one I enter the custom field on.

  3. March 24th, 2010 at 16:58 | #3

    @Sandy It’s strange since my solution works for me and Josh, but you can send me your header.php file to blog (at) unsignedint (dot) and i will have a look at it.

  4. Sandy
    March 25th, 2010 at 22:18 | #4

    @lmmendes

    Header sent .. it removes the sidebar from all pages as soon as i add the code to the header .. without even using a custom field to any page.

  5. March 26th, 2010 at 01:05 | #5

    @Sandy
    Hello Sandy, i made a mistake in the code last time i edit the post and didn’t test the new updated solution, already sent you the answer, via e-mail and updated the post with the correct code.

    The problem was that i used the function “get_post_custom” instead of “get_post_meta”.

    I hope that the works for you.

  6. Sandy
    March 26th, 2010 at 01:52 | #6

    @lmmendes
    Thank you!! Got it working fine now.

  7. November 16th, 2010 at 00:39 | #7

    Hey man, thanks a lot!

    Greetings from Istria! ;)

  8. August 15th, 2011 at 01:09 | #8

    Hello!
    Nice post!
    If somebody needs merely to get the iNove’s sidebar smaller, just read the following article – http://dotnetfollower.com/wordpress/2010/12/get-the-smaller-sidebar-of-inove-theme/
    Thanks!

  1. No trackbacks yet.