First,I know wordpress won't allow you to use template for posts (WooCommerce's product page is built via post). So I look for the Template Hierarchy. It says there:
single-{post-type}-{slug}.php
(Since 4.4). First, WordPress looks for a template for the specific post.For example, if post type is product and the post slug is
dmc-12
, WordPress would look forsingle-product-dmc-12.php
.
single-{post-type}.php
– If the post type is product, WordPress would look forsingle-product.php
.
single.php
– WordPress then falls back tosingle.php
.
singular.php
– Then it falls back tosingular.php
.
index.php
– Finally, as mentioned above, WordPress ultimately falls back toindex.php
.
So I created a template and name it single-product-ccc(ccc is one of my product's slug name), but nothing happened, nothing was affected.
But by creating a template named single-product will affect all of the product pages.
Why is that happening?
I don't get it. Even a single-2313.php
(2313
is one post's id) will overwrite the default single.php
for that 2313
post.
Why single-product-slug is not working in the same way?
Thanks.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire