H
H
HankeTM2020-06-26 11:33:47
WordPress
HankeTM, 2020-06-26 11:33:47

Why does the code from the product template affect the rest of the site? Why do hooks cause PHP errors?

Good afternoon.

The site has a storefront template. I want to try to change the standard product card template to my own.
Found the following way. Creating a php file and telling wordpress what types of posts this template is for.

/*
Template Name: Custom Template
Template Post Type: product
*/


In the admin panel in the product, the choice of the "Custom Template" template appeared, I assumed that everything that I would write in this file would be displayed only in those products where this template was selected. But all the code is distributed to all pages of the site, regardless of the type (page, post, category, product, etc.)

Also, I can't even call get_header(); in this file. Throws an error (Fatal Error: Uncaught Error: Call to a member function get_scripts() on null).

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question