Adding styles/scripts to specific page

You have wp_enqueu_script within your function spelled wrong. It should be wp_enqueue_script. Also is_page_template() will look for your template file as is relative to your theme directory. If file.php is in the root of your theme then it would just be is_page_template(‘file.php’). Here is the reference for that function: https://developer.wordpress.org/reference/functions/is_page_template/ Try this: function test(){ if( … Read more

How can javascript be added to a custom-page.php template?

Save your JS in a seperate file and use a Conditional to Enqueue it. Something like this will work. function my_enqueue_stuff() { if (is_page_template(‘custom-page.php’)) { wp_enqueue_script( ‘my-functions’, get_stylesheet_directory_uri() . ‘/my-functions.js’, array(‘jquery’), filemtime(get_stylesheet_directory() . ‘/my-functions.js’) ); } } add_action( ‘wp_enqueue_scripts’, ‘my_enqueue_stuff’ ); The above will go in your Child Theme’s functions.php file.

Inserting article:tags meta in html head-element, using get tags, no wp_head

Okay, so after some more tinkering, I found another solution. This one works with or without the loop. So adding it in the template file or your single.php is fine, in the <head> of the HTML. <?php $tags = get_the_tags($post->ID); ?> <?php foreach($tags as $tag) : ?> <meta property=”article:tag” content=”<?php print_r($tag->name);?>” /> <?php endforeach; ?> … Read more