Leveraging AI to Supercharge Your WordPress Business Website
In today’s competitive digital landscape, every business website needs an edge to...
Here is a really simple way to create custom tabs for your WooCommerce builds using the ACF Repeater Field.
First, create your repeater field and call it “tabs”. Create 2 sub fields and call them whatever you like, I have used “tab_title” (text field) and “tab_content” (wysiwyg field). Then select to show fields for “Post Type > Product”.
Next, add this to your functions.php file:
<?php
function load_custom_tab( $tab_key, $tab_info ) {
echo apply_filters( 'the_content', $tab_info['tabContent'] );
}
function add_content_tabs( $tabs ) {
global $post;
$custom_tabs = get_field( 'tabs', $post->ID );
if ( $custom_tabs ) :
foreach( $custom_tabs as $index => $tab ) {
$tabs['customTab-' . $index] = array(
'title' => $tab['tab_title'],
'priority' => 20 + $index,
'tabContent' => $tab['tab_content'],
'callback' => 'load_custom_tab'
);
}
endif;
return $tabs;
}
add_filter( 'woocommerce_product_tabs', 'add_content_tabs' );
?>
Thats it!
Links: Gabe, WooCommerce, ACF Repeater Field
Coding Tips, WooCommerce Tips, WordPress Tips
Share
In today’s competitive digital landscape, every business website needs an edge to...
WordPress has come a long way since its humble beginnings in 2003....
In the ever-evolving landscape of website development, staying ahead of the curve...
To stop any page from being deleted by any user role, including admins, add the following code to your functions.php...
I came across this when looking for a purpose built, fully customisable calendar - https://fullcalendar.io/ Im just starting to work with...
A quick way to remove empty p tags from custom shortcodes in Wordpress. <?php add_filter("the_content", "the_content_filter"); function the_content_filter($content) { $block...