Tagged: x
-
AuthorPosts
-
April 27, 2016 at 2:18 pm #902876
marihonaaParticipantHi!
I have a code in place for adding header code to only one page (below)
function scripts_to_head() {
if ( is_page( 382 ) ) { ?><!– Facebook Pixel Code –>
Code cut out
<!– End Facebook Pixel Code –><?php }
}add_action(‘wp_head’, ‘scripts_to_head’);
This works well. Now I want to add different code to another specific page as well. I tried to add an elseif condition (I don’t really know PHP), but it gave me an error. Could you please help?
Code I added below in bold.
function scripts_to_head() {
if ( is_page( 382 ) ) { ?><!– Facebook Pixel Code –>
Code cut out
<!– End Facebook Pixel Code –><?php }
elseif ( is_page( 476 ) {
Want to add different code here
}
}
add_action(‘wp_head’, ‘scripts_to_head’);
April 28, 2016 at 3:11 am #903675
DarshanaModeratorHi there,
Thanks for writing in! Can you try the following sample code.
function scripts_to_head() { if ( is_page( 382 ) ) { ?> <!-- your script here --> <?php } else if ( is_page( 476 ) ) { ?> <!-- your script here --> <?php } } add_action('wp_head', 'scripts_to_head');April 28, 2016 at 5:29 pm #904860
marihonaaParticipantWorks perfectly, thanks 😀
April 29, 2016 at 4:14 am #905370
DarshanaModeratorGlad we were able to help 🙂
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-902876 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
