I have tried the code bellow, but its not working…
Im using the code bellow in a another project and its working, but when Im using the code in wordpress its not workig…
jQuery(function ($) {
var pathname = location.href;
if (pathname === "http://wwww.findx.se/?page_id=10") {
$('.xoxo').css({
display: 'none'
});
$('div#footer').css({
display: 'none'
});
}
if (pathname === "http://www.findx.se/?page_id=9") {
$('.xoxo').css({
display: 'none'
});
$('div#footer').css({
display: 'none'
});
}
if (pathname === "http://www.findx.se/?page_id=8") {
$('.xoxo').css({
display: 'none'
});
$('div#footer').css({
display: 'none'
});
$('#header').hide();
}
});
Generally WordPress will add a class to the body tag that will allow you to select by page. For example for your first rule you could do in your CSS
Check your body tag on the page you are wanting to change to find out what classes you can use. You could also use it in your jQuery selectory
If you are using WordPress, then this might be the solution:
I solved many
jQuery not defined
problems with this.And beside that,
WordPress
adds a class on the body tag. JustFirebug
it and see which class it is in. Than you can style it the way you want. That is much easier actually.I use following in my
functions.php
to add the page slug/name in the body tagAs a result I get following (I’m using pretty URL)
in this cas,
post-taste-javascript-php-part-2-php-5-4
is my page slug andpostid-1281
is id, so I can useOr I can use
So, I doubt (but not sure) that, it could be
Or, you can use the code snippet (given above) in
functions.php
and just changeto (to add your page id)
As a result, it will add something like
page-id10
in yourbody
tag and you can useAlso, alternatively, you can use
You can check the body tag of the given example right here.
Update :
should be (Pass the
jQuery
as argument)Also, make sure,
jQuery
is loaded, usingalert(typeof jQuery);
. if, it showsundefined
thenjQuery
is not loaded, so load it. Check wp_enqueue_script for more.Call your own jQuery JavaScript file, AFTER the wp_head function () located in the header.php file (WordPress).