WooCommerce: Modelo de mudança para uma única página do produto
-
-
Essa lista que você vênatela deediçãoestá disponível apenasparapáginas.Possívelpergunta duplicada: https://wordpress.stackexchange.com/questions/35221/How-Por-Get-Template-drop-down-menu-in-page-attributes-of-custom-post-type https://stackoverflow.com/questions/5652817/select-template-menu-for-custom-post-types.That dropdown you see on the edit page screen is only available for pages. Possible duplicate question: https://wordpress.stackexchange.com/questions/35221/how-to-get-template-drop-down-menu-in-page-attributes-of-custom-post-type https://stackoverflow.com/questions/5652817/select-template-menu-for-custom-post-types
- 0
- 2015-06-03
- Jan Beck
-
[Vocêpodeestarinteressadonaproposta de site WooCommerce!] (Https://area51.stackexchange.com/propossals/80132/wooCommerce)[You may be interested in the WooCommerce site proposal!](https://area51.stackexchange.com/proposals/80132/woocommerce)
- 1
- 2015-06-03
- Tom J Nowell
-
2 respostas
- votos
-
- 2015-06-03
Woo Commerceestáfora dotópico como umplugine nãoespecificamente relacionado ao WordPress,mas o que vocêpodefazer é copiar omodelo de um únicoproduto.PHPpara umapasta WooCommerceno seutemafilho. Alterar onome do arquivoe modificar o arquivoe,em seguida,use
single_template
ou <>template_include
Com atag condicional correta.single_template
function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == 'product') { $single_template = dirname( __FILE__ ) . '/single-template.php'; } return $single_template; } add_filter( 'single_template', 'get_custom_post_type_template' );
template_include
add_filter( 'template_include', 'portfolio_page_template', 99 ); function portfolio_page_template( $template ) { if ( is_page( 'slug' ) ) { $new_template = locate_template( array( 'single-template.php' ) ); if ( '' != $new_template ) { return $new_template ; } } return $template; }
Woo Commerce is off topic as its a plugin and not specifically related to WordPress but what you can do is copy over the single-product.php template to a WooCommerce folder in your child theme. change the file name and modify the file, then use
single_template
ortemplate_include
with the correct conditional tag.single_template
function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == 'product') { $single_template = dirname( __FILE__ ) . '/single-template.php'; } return $single_template; } add_filter( 'single_template', 'get_custom_post_type_template' );
template_include
add_filter( 'template_include', 'portfolio_page_template', 99 ); function portfolio_page_template( $template ) { if ( is_page( 'slug' ) ) { $new_template = locate_template( array( 'single-template.php' ) ); if ( '' != $new_template ) { return $new_template ; } } return $template; }
-
Nenhum destes respondatotalmente apergunta,quefoi "Comofaçopara alterar o arquivo demodeloparapáginas deprodutosespecíficos?"None of these fully answer the question, which was "how do I change the template file for specific product pages?"
- 0
- 2018-11-08
- Chris J Allen
-
- 2015-06-03
Vocêprecisa verificar o WordPress hierarquia demodelo Comofunciona.
.Únicopost #
O único arquivo demodelo depostagem é usadopara renderizar um únicopost. WordPress usa o seguinte caminho:
1.single-{post-type}.php – First, WordPress looks for a template for the specific post type. For example, post type is product, WordPress would look for single-product.php. 2.single.php – WordPress then falls back to single.php. 3.index.php – Finally, as mentioned above, WordPress ultimately falls back to index.php.
Página #
O arquivo demodelo usadopara renderizar umapáginaestática (páginapós-tipo). Observe que,ao contrário de outrostipos depós,página éespecialpara o WordPresse usa o seguintepatch:
1. custom template file – The page template assigned to the page. See get_page_templates(). 2. page-{slug}.php – If the page slug is recent-news, WordPress will look to use page-recent-news.php. 3.page-{id}.php – If the page ID is 6, WordPress will look to use page-6.php. 4. page.php 5. index.php
Para o IDespecífico,vocêpode usar
page-{id}.php
modelo.You need to check WordPress template-hierarchy how it works.
Single Post #
The single post template file is used to render a single post. WordPress uses the following path:
1.single-{post-type}.php – First, WordPress looks for a template for the specific post type. For example, post type is product, WordPress would look for single-product.php. 2.single.php – WordPress then falls back to single.php. 3.index.php – Finally, as mentioned above, WordPress ultimately falls back to index.php.
Page #
The template file used to render a static page (page post-type). Note that unlike other post-types, page is special to WordPress and uses the following patch:
1. custom template file – The page template assigned to the page. See get_page_templates(). 2. page-{slug}.php – If the page slug is recent-news, WordPress will look to use page-recent-news.php. 3.page-{id}.php – If the page ID is 6, WordPress will look to use page-6.php. 4. page.php 5. index.php
For specific id you can use
page-{id}.php
template.
Eu sei que há umapossibilidade de alterar aestrutura/design dapágina doproduto,editando o arquivo
single-product-php
-em umtema de criança.As alteraçõesfeitas desse arquivo afetarãotodas aspáginas doproduto.
Mas como altero o arquivo demodeloparapáginas deprodutosespecíficos?Comoeuposso com ummodelo depáginapersonalizado?Do zeronão hámodelo suspensoem uma únicapágina doproduto,como se há umapágina (aimagem).
Como altero omodelo de umapágina deprodutoespecífica?
I know there is a possibility to change the structure/design of the product page by editing the file
single-product-php
- in a child-theme.The changes made of that file will affect all the product pages.
But how do I change the template file for specific product pages? Like I can with a custom page template? From scratch there is no template dropdown on a single product page like there is for a page (the image).
How do I change the template of a specific product page?