WooCommerce: Cambia modello per pagina prodotto singolo
-
-
Ilmenu a discesa che vedinella schermata dellapagina dimodifica è disponibile soloper lepagine.Possibile domanda duplicata: 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-typesThat 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
-
[Potrestiessereinteressato allaproposta del sito WooCommerce!] (Https://area51.stackexchange.com/proposals/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 risposta
- voti
-
- 2015-06-03
Woo Commerce èfuoritemain quanto è unplugine non è specificamente correlato a WordPress,ma quello chepuoifare è copiareilmodello single-product.phpin una cartella WooCommerceneltuo childtheme. cambiailnome delfilee modificailfile,quindi utilizza
single_template
otemplate_include
coniltag condizionale corretto.<"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; }
-
Nessuno di questi rispondein modo completo alla domanda,ovvero "comefaccio amodificareilfilemodelloperpagine diprodotto specifiche?"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
Devi controllare la gerarchia deimodelli di WordPress comefunziona.
/p>
Post singolon.
Ilfilemodello dipost singolo viene utilizzatoper visualizzare un singolopost. WordPress utilizzail seguentepercorso:
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.
Paginan.
Ilfilemodello utilizzatopereseguireil rendering di unapagina statica (post-tipo dipagina). Nota che,a differenza di altritipi dipost,lapagina è specialeper WordPresse utilizza la seguentepatch:
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
Per unid specificopuoi utilizzareilmodello
page-{id}.php
.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.
So cheesiste lapossibilità di cambiare la struttura/il design dellapagina delprodottomodificandoilfile
single-product-php
-in un child-theme.Lemodifiche apportate a quelfileinteresserannotutte lepagine delprodotto.
Ma comefaccio amodificareilfilemodelloperpagine diprodotti specifici?Comepossofare con unmodello dipaginapersonalizzato?Da zerononesiste unmenu a discesa deimodelli su una singolapagina diprodotto comeper unapagina (l'immagine).
Comefaccio amodificareilmodello di unapagina diprodotto specifica?