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

How can I use a specific wordpress page template if certain words are used in page title [closed]

You can adjust the template to use in the fly based on the type of page you’re viewing. https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include add_filter( ‘template_include’, ‘portfolio_page_template’, 99 ); function portfolio_page_template( $template ) { if ( is_page( ‘portfolio’ ) ) { $new_template = locate_template( array( ‘portfolio-page-template.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } … Read more

Shortcode or Template Page

Actually it depends. If you’re adding the functionality through a custom plugin or any third party solution rather than theme then the shortcode is best, otherwise you can use a template. You also can use template file with plugin, but then the theme and the plugin will be tightly coupled. That’s kinda not preferred. But … 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’ );

How do I set content in my pages so that it remains permanent while blog posts are added below?

If you want to show that static content in your post then you can find post.php template in your theme and find function “the_content();” just before this function make a div for your static content and add our static content there. Similarly if you want to show that content in page then find page.php template … Read more