Hey Peter,
Before I give a suggestion, please note that we are not responsible for issues arising from the use of custom code or third party plugins even if it’s suggested here in the forum. They were only meant to provide some guidance or idea on how to extend the functionality of our products but they’re beyond the scope of our support.
The code provided in the past thread is not good because it disrupts the position of the sidebar. Please remove the code you copied and instead of custom coding, I’d recommend that you use a third party plugin like Sticky Menu (or Anything!) on Scroll
Below is a screencast showing how to achieve a sticky sidebar in X but please refer to the third party plugin’s documentation for complete details and contact the plugin’s support if you encounter a problem. If you need a features, it would be best to consult with a third party developer.
Thanks.