Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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...

.classname{
  position:relative;
  top:-300;
}

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...

share|improve this question

migrated from stackoverflow.com May 29 '12 at 13:59

This question came from our site for professional and enthusiast programmers.

    
Added WordPress tags. Removed jQuery tag. –  Sam May 29 '12 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 May 29 '12 at 13:57
    
No need for jQuery here –  Pekka 웃 May 29 '12 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;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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