Support » Theme: Flat Responsive » Child function not working

  • I ‘ve added the following code to my child theme’s functions.php. However, it does not work. It works fine if I add it to the parent functions.php Other functions in the child theme seem to work fine.

    function remove_comment_website_field( $fields ){
    if(isset($fields[‘url’]))
    unset($fields[‘url’]);
    return $fields;
    }
    add_filter( ‘comment_form_default_fields’, ‘remove_comment_website_field’ );

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Theme Author Styled Themes

    (@gejay)

    Hello sprockettechweb,

    Could you please specify and let us know what changes you’re trying to make?

    [ Signature deleted ]

    • This reply was modified 11 months, 3 weeks ago by Jan Dembowski.
    • This reply was modified 11 months, 3 weeks ago by Jan Dembowski.
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @gejay Thanks for the great support but please lose the signature. That’s prohibited in these forums as it’s been horribly abused in the past by others.

    Thanks!
    Styled Themes Support.

    Yes, bad people ruin it for others. No, I’m not kidding. Please refrain from that.

    https://wordpress.org/support/guidelines/#avoid-signatures

    I added the above function. It should remove the website field from the comment form.

    Theme Author Styled Themes

    (@gejay)

    Thanks for the info @jdembowski !

    And sprockettechweb,

    Could you please provide us the reference to your child theme? Or please activate the child theme and let us know if there is no any issue associated to the child theme you’re using.

    Best Regards,

    The child theme is active? The only issue I’ve encountered is this one with the function not working in the child functions.php Other functions seem to work fine.

    Theme Author Styled Themes

    (@gejay)

    Hello sprockettechweb,

    I’m afraid your website still shows the parent theme while detecting from our end.
    Please share us the structure of your child theme’s functions.php file.

    Thanks!

    Strange. Here’s the code.

    <?php
    // Exit if accessed directly
    if ( !defined( ‘ABSPATH’ ) ) exit;

    // BEGIN ENQUEUE PARENT ACTION
    // AUTO GENERATED – Do not modify or remove comment markers above or below:

    if ( !function_exists( ‘chld_thm_cfg_parent_css’ ) ):
    function chld_thm_cfg_parent_css() {
    wp_enqueue_style( ‘chld_thm_cfg_parent’, trailingslashit( get_template_directory_uri() ) . ‘style.css’, array( ) );
    }
    endif;
    add_action( ‘wp_enqueue_scripts’, ‘chld_thm_cfg_parent_css’, 10 );

    // END ENQUEUE PARENT ACTION

    //hide website field in comment form
    function remove_website_field( $fields ){
    if(isset($fields[‘url’]))
    unset($fields[‘url’]);
    return $fields;
    }
    add_filter( ‘comment_form_default_fields’, ‘remove_website_field’ );

    //hide login ID from blog posts
    add_filter( ‘request’, ‘wpse5742_request’ );
    function wpse5742_request( $query_vars )
    {
    if ( array_key_exists( ‘author_name’, $query_vars ) ) {
    global $wpdb;
    $author_id = $wpdb->get_var( $wpdb->prepare( “SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key=’nickname’ AND meta_value = %s”, $query_vars[‘author_name’] ) );
    if ( $author_id ) {
    $query_vars[‘author’] = $author_id;
    unset( $query_vars[‘author_name’] );
    }
    }
    return $query_vars;
    }
    add_filter( ‘author_link’, ‘wpse5742_author_link’, 10, 3 );
    function wpse5742_author_link( $link, $author_id, $author_nicename )
    {
    $author_nickname = get_user_meta( $author_id, ‘nickname’, true );
    if ( $author_nickname ) {
    $link = str_replace( $author_nicename, $author_nickname, $link );
    }
    return $link;
    }

    Theme Author Styled Themes

    (@gejay)

    Hello @sprockettechweb,

    In your functions.php please add and check for the hook one for removing the website field only, otherwise we need to investigate it further.

    Let us know.
    Thanks!

    Sorry, I’m not sure I understand. Do you want me to add an “if( !function_exists” before the function?

    Theme Author Styled Themes

    (@gejay)

    Hello sprockettechweb,

    Please add the following inside your child theme’s functions.php file and let us know;

    add_action( 'after_setup_theme', 'fr_add_comment_url_filter' );
    function fr_add_comment_url_filter() {
        add_filter( 'comment_form_default_fields', 'fr_disable_comment_url', 20 );
    }
    
    function fr_disable_comment_url($fields) {
        unset($fields['url']);
        return $fields;
    }

    Thanks!

    That worked, thank you!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Child function not working’ is closed to new replies.