Hi,
i need to add this code to the <head> section for specific pages only:
<head>
<script type="module" src="./mapplic.js"></script>
<link rel="stylesheet" href="./mapplic.css">
</head>
How can i do that?
kind regards
Jak
Hey Jak73,
Try adding this code to the end of your child theme functions.php file in Appearance ▸ Editor and change the page IDs in the array to the ones you want to use, then add your snippet
function my_code() {
if(is_page( array(206, 591, 597) ) )
{
?>
//Put Your Code Here
<?php
}
}
add_action( 'wp_head', 'my_code' );
Best regards,
Mike
Hi Mike,
where do i add the page id (489)?
How ca i add more then one page (for example page 500, 501,502 too)?
Like this:
function my_code() {
if(is_page( array(489, 501, 502) ) )
{
?>
<script type="module" src="./mapplic.js"></script>
<link rel="stylesheet" href="./mapplic.css">
<?php
}
}
add_action( 'wp_head', 'my_code' );
?
kind regards
Jak
Hi,
Thank you for the update.
Yes, the code and the placement of the argument or array values in the conditional function looks correct. You can add more page IDs if needed. Here’s the formatted version:
function my_code() {
if ( is_page( array( 489, 501, 502, 123 ) ) ) {
?>
<script type="module" src="./mapplic.js"></script>
<link rel="stylesheet" href="./mapplic.css">
<?php
}
}
add_action( 'wp_head', 'my_code' );
Best regards,
Ismael