Need help in creating splash intro page using custom page template

Let’s go from the beginning. First I’ll walk you through the enqueing of styles and scripts. In your functions.php file add: add_action( ‘wp_enqueue_scripts’, ‘splash_intro_scripts’); if ( ! function_exists( ‘splash_intro_scripts’ ) ){ function splash_intro_scripts() { if (is_page_template(‘page-intro.php’)) { wp_enqueue_style(‘google_font_1’, ‘https://fonts.googleapis.com/css?family=Arvo&subset=latin,latin-ext’); wp_enqueue_style(‘google_font_2’, ‘https://fonts.googleapis.com/css?family=Josefin+Sans&subset=latin,latin-ext’); wp_enqueue_style(‘google_font_3’, ‘https://fonts.googleapis.com/css?family=Josefin+Slab&subset=latin,latin-ext’); wp_enqueue_script( ‘bootstrap’, get_stylesheet_directory_uri().’/js/bootstrap.js’, array( ‘jquery’ ),”, false ); wp_enqueue_script( ‘blocs’, get_stylesheet_directory_uri().’/js/blocs.js’, array( … Read more

Using a page-template to restrict access based on IP (Frontend)

Now I have it working! In the meanwhile Jeff Cohan also gave the right advice on how to do it (see his comment on the question). Here’s my full code, working the way he suggested: function getUserIP() { $client = @$_SERVER[‘HTTP_CLIENT_IP’]; $forward = @$_SERVER[‘HTTP_X_FORWARDED_FOR’]; $remote = $_SERVER[‘REMOTE_ADDR’]; if (filter_var($client, FILTER_VALIDATE_IP)) {$ip=$client;} elseif (filter_var($forward, FILTER_VALIDATE_IP)) {$ip=$forward;} … Read more

require happens out of order

Must be something with your setup. Following works for me (inside child theme – should work for any theme though): single.php: global $post; $bla = $post->post_title; error_log(‘post title is: ‘ . $bla); include(‘included.php’); included.php: error_log(‘i am included file: ‘ . $bla); Output in debug.log: post title is: Hello test i am included file: Hello test … Read more

How to get template link?

If you’re using that template for only one page, you can try this function: /** * @param string $template Base name of the template. */ function wpse_233924_get_page_link($template) { $query = new \WP_Query; // Get page which is using the $template. $page = $query->query([ ‘post_type’ => ‘page’, ‘meta_key’ => ‘_wp_page_template’, ‘meta_value’ => $template, ‘no_found_rows’ => 1, … Read more

Target pages using Woo Commerce single product page template

You can use is_product() WooCommerce conditional tag to identify if its single product page. Below is example code which enqueues test.js if its a single product page. You may use and tweak this code snippet further. function mytheme_scripts() { if ( is_product() ) { wp_enqueue_script( ‘test-js’, get_template_directory_uri() . ‘/js/test.js’, array() ); } } add_action( ‘wp_enqueue_scripts’, … Read more

page_template filter without a plugin

After some digging I found a better function which allows you to directly modify the template listing function page_templates( $templates ) { $templates[‘temp/template1.php’] = ‘Full Width Template’; return $templates; } add_filter( ‘theme_page_templates’, ‘page_templates’ );