I am working in a premium wordpress theme... It is a complex wordpress theme with lots of admin features so i feel very difficult to edit... Now i need to move a sidebar upwards only in homepage... i use this code...


But the code above is moving the sidebar on all pages... since the site is complex i don't know where to add specific class name for sidebar in homepage... So i decided to use jQuery to find whether the page is home page or not... if it is homepage then i move the sidebar upwards, else not...

Please say me how to find whether the page is homepage or not using jQuery...

  • Added WordPress tags. Removed jQuery tag.
    – Sam
    Commented May 29, 2012 at 13:57
  • and why/how do you think jQuery should figure out whether it's the startpage or not? you have php as your backend - do your magic within this framework!
    – Andreas Niedermair
    Commented May 29, 2012 at 13:57
  • No need for jQuery here
    – Pekka
    Commented May 29, 2012 at 14:01

1 Answer 1


WordPress adds a series of classes to the body tag (assuming your theme-designer used body_class()) depending on which page you're currently viewing. On the homepage, WordPress adds the home class. You could use this to target only the sidebar viewed on the homepage:

body.home .classname {
    position: relative;
    top: -300px;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.