Right Sidebar Sticky Menu

Hey guys,

I was hoping you could enlighten me as to if you use a plugin for your sticky menu on your blog as I would like to do something similar.

I am currently using your custom sidebars on the left which works well but am hoping to have a menu on the right to skip to certain subjects on the page.

Thanks

  • Sohag Ronjon Dey

    Hi Baldafrican,

    Hope you are doing well. :slight_smile:

    I have tried to create a sticky widget area in my test site and it worked with the following code.
    I have added the following to my theme's style.css

    #cp_course_structure-2 {
      position: absolute;
      top: 0;
      margin-top: 20px;
      border-top: 1px solid purple;
      padding-top: 19px;
    }
    
    #cp_course_structure-2.fixed {
      position: fixed;
      top: 0;
    }

    and the following javascript in the footer.php after wp_footer(); and before the closing </body>

    <script type="text/javascript">
    (function ($){
    	$(document).ready(function () {
    	  var top = $('#cp_course_structure-2').offset().top - parseFloat($('#cp_course_structure-2').css('marginTop').replace(/auto/, 0));
    	  $(window).scroll(function (event) {
    		// what the y position of the scroll is
    		var y = $(this).scrollTop();
    
    		// whether that's below the form
    		if (y >= top) {
    		  // if so, ad the fixed class
    		  $('#cp_course_structure-2').addClass('fixed');
    		} else {
    		  // otherwise remove it
    		  $('#cp_course_structure-2').removeClass('fixed');
    		}
    	  });
    	});
    })(jQuery);
    </script>

    Please try this by changing the #cp_course_structure-2 with your widgets id attribute value in the above codes.

    Hope this helps.
    Please let us know if you need any further help.

    Cheers,
    Sohag

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.