Announcement

Collapse
No announcement yet.

Don't Show Primary Sidebar on Certain Pages

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Don't Show Primary Sidebar on Certain Pages

    I created a custom widget area on http://beta.fightaholic.com, and I set it to display only on posts from the MMA Fights Category. The issue I am having is that the Primary Sidebar Widget Area shows up along with my custom widget area (ex post: http://beta.fightaholic.com/allen-vs...ma-atlanta-ga/). How can I disable the Primary Sidebar Area for only posts in the MMA Fights Category? I only want the custom widget area showing and not the Primary Sidebar Area.

    Thank you in advance.

  • #2
    There are plugins to choose where to display Genesis sidebars but if your custom widget is IN the primary sidebar you can not choose to not display the primary sidebar area as your widget will be gone with it, too.

    Maybe try a custom widget area with a hook location outside of the sidebar?

    Comment


    • #3
      If widget is in custom sidebar:
      PHP Code:
      add_action('get_header','cd_change_genesis_sidebar');
      function 
      cd_change_genesis_sidebar() {
          if (
      is_archive() && is_category'my-category-name' ) || is_single() && in_category('my-category-name')) { // Check if we're on a single post for custom category
              
      remove_action'genesis_sidebar''genesis_do_sidebar' ); //remove the default genesis sidebar
              
      add_action'genesis_sidebar''cd_do_sidebar' ); //add an action hook to call the function for my custom sidebar
          
      }
      }

      //Function to output my custom sidebar
      function cd_do_sidebar() {
          
      dynamic_sidebar'your-custom-sidebar' );


      Combining these:
      http://www.carriedils.com/sidebar-custom-post-type/

      http://cobaltapps.club/forum/ma...archive-single

      Comment


      • #4
        Kellyise,

        I already have the custom sidebar showing up for posts in the category through the custom widget and conditional sections in the admin. I was unable to disable the primary sidebar with the following code:

        function cd_change_genesis_sidebar() {
        if (in_category('7')) { // Check if we're on a single post for custom category
        remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
        }
        }

        add_action('get_header','cd_change_genesis_sidebar ');


        7 is the category tag ID.




        Comment


        • SiGa
          SiGa commented
          Editing a comment
          Did you try is_category instead of in_category?

      • #5
        SiGa,

        I changed it, but the Primary Sidebar is still showing. I even moved the custom widget area to the genesis_after_sidebar_widget_area. Here is a post inside that category:

        http://beta.fightaholic.com/allen-vs...ma-atlanta-ga/

        And below s what is in the Dynamik custom functions section.

        <?php
        /* Do not remove this line. Add your functions below. */

        function cd_change_genesis_sidebar() {
        if (is_category('7')) { // Check if we're on a single post for custom category
        remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
        }
        }

        add_action('get_header','cd_change_genesis_sidebar ');


        //* Customize the credits
        add_filter( 'genesis_footer_creds_text', 'sp_footer_creds_text' );
        function sp_footer_creds_text() {
        echo '<div class="creds"><p>';
        echo 'Copyright &copy; ';
        echo date('Y');
        echo ' Fightaholic. Design by <a href="http://www.mrtechnique.com" target="_blank">Mr. Technique</a>.';
        echo '</p></div>';
        }

        //* Create fighter taxonomy
        function create_my_taxonomies() {
        register_taxonomy('fighters', 'post', array(
        'hierarchical' => false, 'label' => 'Fighters',
        'query_var' => true, 'rewrite' => true));
        }
        add_action('init', 'create_my_taxonomies', 0);


        I'm stumped.



        Comment


        • #6
          I finally figured out the issue!!!! It was the Genesis Simple Sidebars plugin that was causing the issue. I disabled the plugin, and the Primary Sidebar disappears for posts in that cateogry.

          Comment


          • SiGa
            SiGa commented
            Editing a comment
            Ah yes. You can´t combine the Simple Sidebar plugin and custom code for sidebars, that won´t go well together. (btw: For PHP, click on "A" and use the PHP button - the code will be better readable then, also)
        Working...
        X