Avada Forums Community Forum ->Functions.php in child theme -> please help me solving the fatal error.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Alex Ander
    Participant
    Post count: 10

    Hi!

    I want to use advanced custom fields pro i.c.w. avada to enhance my product detail page.
    Now I have figured out how to activate the child theme from Avada.
    I have the code (not written myself) that I want to use in the child theme to call on advanced custom fields pro.
    I am not a developer so I have the code copied from someone with knowledge on how to do so.

    I have added this code in the child theme’s function.php. But as soon as I upload this function.php to the child theme folder and refrehs the browser I get a fatal error.

    How can I debug/solve this.
    The code that I want to add to activate the advanced custom fields pro is this one:

    function sf_custom_woo_urls(){
    
    $rows = get_field('ext_urls');
    
    if( $rows' ) {
    echo '<ul class="ext_urls">';
    foreach( $rows as $row) {
    $icon = $row[ícon'];
    $url = $row['url'];
    $text = $row['text'];
    echo '<li> <a href="',esc_url_raw($url).'" target="_blank" rel="noopener">';
    echo $icon;
    echo ' '.$text;
    echo '</a></li>';
    }
    echo '</ul>';
    }
    }
    
    add_action('woocommerce_after_add_to_cart_button','sf_custom_woo_urls');

    The child themes function.php standard content is this (which seems correct)

    <?php
    
    function theme_enqueue_styles() {
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', [] );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 20 );
    
    function avada_lang_setup() {
    	$lang = get_stylesheet_directory() . '/languages';
    	load_child_theme_textdomain( 'Avada', $lang );
    }
    add_action( 'after_setup_theme', 'avada_lang_setup' );

    So in my logic (but I could be wrong) the child theme function.php that I need to use should be

    <?php
    
    function theme_enqueue_styles() {
        wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', [] );
    }
    add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 20 );
    
    function avada_lang_setup() {
    	$lang = get_stylesheet_directory() . '/languages';
    	load_child_theme_textdomain( 'Avada', $lang );
    }
    add_action( 'after_setup_theme', 'avada_lang_setup' );
    
    function sf_custom_woo_urls(){
    
    $rows = get_field('ext_urls');
    
    if( $rows' ) {
    echo '<ul class="ext_urls">';
    foreach( $rows as $row) {
    $icon = $row[ícon'];
    $url = $row['url'];
    $text = $row['text'];
    echo '<li> <a href="',esc_url_raw($url).'" target="_blank" rel="noopener">';
    echo $icon;
    echo ' '.$text;
    echo '</a></li>';
    }
    echo '</ul>';
    }
    }
    
    add_action('woocommerce_after_add_to_cart_button','sf_custom_woo_urls');<code></code>

    Please help and let me know if more info is needed.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.