Hey @paupau1
Sorry for responding late. Right now there’s no such option in our plugin.
For this specific task, you can use WordPress’s default wp_head hook for this purpose.
I have also made a snippet for you so you won’t have to do anything but copy and paste it into your child theme’s functions.php file.
/**
* Show certain scripts on certain post type/s.
*
* @return string The scripts for specific post types.
*/
function hnf_custom_head_scripts() {
if ( 'post' === get_post_type( get_the_ID() ) ) {
echo '<script> //Your Code goes here </script>';
}
}
Note: Do remember to change the post type according to your need.
Let me know if you need any assistance. 🙂
Have a nice day!
Hi,
Thank you for the reply, I’m not good at php. I add this script in the function.php of the child theme to test and it not show hello world in post, does I need to add the id of the posts our something ? The idea is to add it to every posts.
/**
* Show certain scripts on certain post type/s.
*
* @return string The scripts for specific post types.
*/
function hnf_custom_head_scripts() {
if ( 'post' === get_post_type( get_the_ID() ) ) {
echo '<script> Hello world </script>';
}
}
Thank you for your time,
Regards,
PM
Hey @paupau1
You don’t need to add any post id in the script. It might have been a cache issue on your site which is why you were not able to see the changes, I have added the above script to show a script only on posts and it worked fine.
Here I have made a short screencast for you as well: [ Helping Screencast ].
If you are having problems in implementing the solution or facing any other problem/s kindly contact our support forum.
Have a good day.