Ich versuche, WooCommerce drei benutzerdefinierte Registerkarten hinzuzufügen. Ich habe den Code unten und zwei von ihnen zeigen, aber aus irgendeinem Grund wird die Registerkarte Attributbeschreibung nicht auf der Seite angezeigt. Nicht nur, dass die Registerkarte Mengenpreis ihre Beschreibung nicht zeigt. Ich habe versucht, die verschiedenen Abschnitte des Codes an verschiedenen Orten zu verschieben, und ich habe den Code auf Fehler oder fehlende Abschnitte überprüft. Das ist so nah wie möglich.Hinzufügen mehrerer Registerkarten zu einzelnen WooCommerce-Produktseiten
Mein Prozess besteht darin, die vorhandenen Registerkarten, die ich nicht will, zu entfernen und dann neue in der Reihenfolge hinzuzufügen, in der sie angezeigt werden sollen.
Ich habe das Gefühl, dass mir etwas fehlt.
Sie die Seite hier sehen können: http://demo.bergdahl.com/product/6-oz-catridge/
Hier ist der Code ich verwende:
// WooCommerce Tabs
// REMOVE EXISTING TABS
add_filter('woocommerce_product_tabs', 'woo_remove_product_tabs', 98);
function woo_remove_product_tabs($tabs) {
unset($tabs['description']); // Remove the description tab
// unset($tabs['reviews']); // Remove the reviews tab
unset($tabs['additional_information']); // Remove the additional information tab
return $tabs;
}
// ADD ATTRIBUTE DESCRIPTION TAB
add_filter('woocommerce_product_tabs', 'woo_attrib_desc_tab');
function woo_attrib_desc_tab($tabs) {
// Adds the Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __('Desc', 'woocommerce'),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
return $tabs;
}
// ADD QUANTITY PRICING TAB
add_filter('woocommerce_product_tabs', 'woo_qty_pricing_tab');
function woo_qty_pricing_tab($tabs) {
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __('Quantity Pricing', 'woocommerce'),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
return $tabs;
}
// ADD OTHER PRODUCTS TAB
add_filter('woocommerce_product_tabs', 'woo_other_products_tab');
function woo_other_products_tab($tabs) {
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __('Other Products', 'woocommerce'),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
}
// ADD CUSTOM TAB DESCRIPTIONS
function woo_attrib_desc_tab_content() {
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
}
function woo_qty_pricing_tab_content() {
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here\'s your quantity pricing tab.</p>';
}
function woo_other_products_tab_content() {
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here\'s your other products tab.</p>';
}
bearbeiten pro Antwort von LoicTheAztec unten, das ist meine ganze functions.php-Datei. Ich versuchte es mit und ohne ?>
am Boden:
<?php
add_theme_support('builder-3.0');
add_theme_support('builder-responsive');
function register_my_fonts() {
wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700');
wp_enqueue_style('googleFonts-OpenSans');
}
add_action('wp_enqueue_scripts', 'register_my_fonts');
function sc_replacecolon($content){ return str_replace('[sc:', '[sc name=', $content); }
add_filter('the_content', 'sc_replacecolon', 5);
/* WOOCOMMERCE */
add_filter('woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1);
function woo_custom_product_tabs($tabs) {
// 1) Removing tabs
unset($tabs['description']); // Remove the description tab
// unset($tabs['reviews']); // Remove the reviews tab
unset($tabs['additional_information']); // Remove the additional information tab
// 2 Adding new tabs
//Attribute Description tab
$tabs['attrib_desc_tab'] = array(
'title' => __('Desc', 'woocommerce'),
'priority' => 100,
'callback' => 'woo_attrib_desc_tab_content'
);
// Adds the qty pricing tab
$tabs['qty_pricing_tab'] = array(
'title' => __('Quantity Pricing', 'woocommerce'),
'priority' => 110,
'callback' => 'woo_qty_pricing_tab_content'
);
// Adds the other products tab
$tabs['other_products_tab'] = array(
'title' => __('Other Products', 'woocommerce'),
'priority' => 120,
'callback' => 'woo_other_products_tab_content'
);
return $tabs;
}
// New Tab contents
function woo_attrib_desc_tab_content() {
// The attribute description tab content
echo '<h2>Description</h2>';
echo '<p>Custom description tab.</p>';
}
function woo_qty_pricing_tab_content() {
// The qty pricing tab content
echo '<h2>Quantity Pricing</h2>';
echo '<p>Here\'s your quantity pricing tab.</p>';
}
function woo_other_products_tab_content() {
// The other products tab content
echo '<h2>Other Products</h2>';
echo '<p>Here\'s your other products tab.</p>';
}
?>
"Es brach die Website" ist 95% der Zeit ein Syntaxfehler. Sie können eine nützlichere Fehlerbeschreibung erhalten, indem Sie ['WP_DEBUG'] (https://codex.wordpress.org/Debugging_in_WordPress) aktivieren. – helgatheviking
Ich habe den Code von Loic oben in meiner functions.php hinzugefügt und erhalte: Parse error: Syntaxfehler, unerwarteter 'add_filter' (T_STRING) in/home/parkyma/public_html/demo/wp-content/themes/BuilderChild-Default/functions.php on line 1 – MattM
Der Fehler sagt, dass es in Zeile 1 ist, was, wenn ich raten musste, ein Problem mit dem 'functions.php' des übergeordneten Themas anzeigt. Ich habe deine gesamte 'functions.php' von oben als ein Kinderthema von Twenty Sixteen verwendet und es erzeugt keine Fehler. – helgatheviking