• I made a new tab with ACF and implemented it in my themes function.php and it works perfectly as it should. But I need another tap too, and when I implement it in the same way as the first, I get the following error:

    Fatal error: Can not ready clare nova_wp_product_tabs () (previously Declared in /var/www/www.wannafinddemo5.dk/www/wp-content/themes/nova-wp/functions.php:15) in /var/www/www.wannafinddemo5 .com / www / wp-content / themes / nova-wp / functions.php on line 61
    How do I fix that problem?
    Here is how I implemented both taps in my themes function.php

    <?php
    /**
    * Nova WP engine room
    *
    * @package nova-wp
    */

    /**
    * Initialize all the things.
    */

    require get_stylesheet_directory() . ‘/inc/init.php’;
    add_filter( ‘woocommerce_product_tabs’, ‘nova_wp_product_tabs’ );

    function nova_wp_product_tabs( $tabs ) {

    // ensure ACF is available
    if ( !function_exists( ‘get_field’ ) )
    return;

    $content = trim( get_field( ‘levering’ ) );

    if ( !empty( $content ) ) {

    $tabs[] = array(
    ‘title’ => ‘Levering’,
    ‘priority’ => 15,
    ‘callback’ => ‘nova_wp_levering’
    );

    }

    return $tabs;
    }

    function nova_wp_levering() {
    echo get_field( ‘levering’ );
    }
    require get_stylesheet_directory() . ‘/inc/init.php’;
    add_filter( ‘woocommerce_product_tabs’, ‘nova_wp_product_tabs’ );

    function nova_wp_product_tabs( $tabs ) {

    // ensure ACF is available
    if ( !function_exists( ‘get_field’ ) )
    return;

    $content = trim( get_field( ‘plantning_og_pasning’ ) );

    if ( !empty( $content ) ) {

    $tabs[] = array(
    ‘title’ => ‘Plantning og pasning’,
    ‘priority’ => 15,
    ‘callback’ => ‘nova_wp_plantning_og_pasning’
    );

    }

    return $tabs;
    }

    function nova_wp_plantning_og_pasning() {
    echo get_field( ‘plantning_og_pasning’ );
    }

    what is wrong making two taps in that way?

Viewing 6 replies - 1 through 6 (of 6 total)
  • You have declare the function ‘nova_wp_product_tabs’ twice one function cannot be declare more than once please rename the second function.

    Thread Starter jensarne

    (@jensarne)

    Thank you!
    I am beginner in php code , so I do not know how to rename a function. ??
    Can you help?

    Put below code in your function.php file and remove old one.

    <?php
    /**
    * Nova WP engine room
    *
    * @package nova-wp
    */
    /**
    * Initialize all the things.
    */

    require get_stylesheet_directory() . ‘/inc/init.php’;
    add_filter( ‘woocommerce_product_tabs’, ‘nova_wp_product_tabs’ );

    function nova_wp_product_tabs( $tabs ) {

    // ensure ACF is available
    if ( !function_exists( ‘get_field’ ) )
    return;

    $content = trim( get_field( ‘levering’ ) );

    if ( !empty( $content ) ) {

    $tabs[] = array(
    ‘title’ => ‘Levering’,
    ‘priority’ => 15,
    ‘callback’ => ‘nova_wp_levering’
    );

    }

    return $tabs;
    }

    function nova_wp_levering() {
    echo get_field( ‘levering’ );
    }
    require get_stylesheet_directory() . ‘/inc/init.php’;
    add_filter( ‘woocommerce_product_tabs’, ‘nova_wp_product_tabs_second’ );

    function nova_wp_product_tabs_second( $tabs ) {

    // ensure ACF is available
    if ( !function_exists( ‘get_field’ ) )
    return;

    $content = trim( get_field( ‘plantning_og_pasning’ ) );

    if ( !empty( $content ) ) {

    $tabs[] = array(
    ‘title’ => ‘Plantning og pasning’,
    ‘priority’ => 15,
    ‘callback’ => ‘nova_wp_plantning_og_pasning’
    );

    }

    return $tabs;
    }

    function nova_wp_plantning_og_pasning() {
    echo get_field( ‘plantning_og_pasning’ );
    }

    Thread Starter jensarne

    (@jensarne)

    Now I get this error:
    Parse error: syntax error, unexpected ‘<‘ in /var/www/www.wannafinddemo5.dk/www/wp-content/themes/nova-wp/functions.php on line 11

    Please Check syntax error in function file may be “<?php” on line 11 not required.

    Thread Starter jensarne

    (@jensarne)

    It did not solve the problem. Now I get this error:

    Fatal error: Cannot redeclare nova_wp_remove_stuff() (previously declared in /var/www/www.wannafinddemo5.dk/www/wp-content/themes/nova-wp/inc/structure/hooks.php:13) in /var/www/www.wannafinddemo5.dk/www/wp-content/themes/nova-wp/inc/structure/hooks.php on line 24

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Advanced Custom Field’ is closed to new replies.