Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
September 4, 2024 at 1:39 pm #1466216
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
JakSeptember 4, 2024 at 6:05 pm #1466240Hey 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 snippetfunction my_code() { if(is_page( array(206, 591, 597) ) ) { ?> //Put Your Code Here <?php } } add_action( 'wp_head', 'my_code' );Best regards,
MikeSeptember 4, 2024 at 6:09 pm #1466241Hi 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-
This reply was modified 1 year, 2 months ago by
Jak73.
September 5, 2024 at 4:19 am #1466268Hi,
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 -
This reply was modified 1 year, 2 months ago by
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.
