• Hi there wordpressers =)

    Im a bit new to wordpress and I have a question regarding overrides of the functions.php in my theme. I have read some tutorials how to override a part of the functions.php but I cannot get it for my needs.

    Follwoing problem. I have a function in my parent functions.php that have this content:

    function streamtube_setup() { //remove_theme_support( ‘widgets-block-editor’ ); /* * Make theme available for translation. */ load_theme_textdomain( ‘streamtube’, get_template_directory() . ‘/languages’ ); // Add default posts and comments RSS feed links to head. add_theme_support( ‘automatic-feed-links’ ); /* * Let WordPress manage the document title. */ add_theme_support( ‘title-tag’ ); add_image_size( ‘streamtube-image-medium’, 560, 315, true ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.www.ads-software.com/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( ‘post-thumbnails’ ); set_post_thumbnail_size( 1568, 800 ); register_nav_menus( array( ‘primary’ => esc_html__( ‘Primary Menu’, ‘streamtube’ ) ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( ‘html5’, array( ‘comment-form’, ‘comment-list’, ‘gallery’, ‘caption’, ‘style’, ‘script’, ‘navigation-widgets’, ) ); /** * Add support for core custom logo. * * @link https://codex.www.ads-software.com/Theme_Logo */ add_theme_support( ‘custom-logo’, array( ‘flex-width’ => true, ‘flex-height’ => true, ‘unlink-homepage-logo’ => false, ) ); // Add theme support for selective refresh for widgets. add_theme_support( ‘customize-selective-refresh-widgets’ ); // Add support for Block Styles. add_theme_support( ‘wp-block-styles’ ); // Add support for full and wide align images. add_theme_support( ‘align-wide’ ); // Custom background color. add_theme_support( ‘custom-background’, array( ‘default-color’ => ‘#f6f6f6’, ) ); // Add support for responsive embedded content. add_theme_support( ‘responsive-embeds’ ); add_theme_support(‘woocommerce’);}add_action( ‘after_setup_theme’, ‘streamtube_setup’ );

    What I now want is simply overwriting the part:

    add_image_size( ‘streamtube-image-medium’, 560, 315, true );

    in

    add_image_size( ‘streamtube-image-medium’, 350, 200, true );

    I just want to change the thumbnail size. Can anybody help me out how this have to be assigned to the functions.php of the child theme?

    Thanks for your help,

    kweb

Viewing 2 replies - 1 through 2 (of 2 total)
  • Unfortunately, your source code is very difficult to read here. Please try to use the code block available in the editor here.

    Regarding your question: you would have to remove the size with https://developer.www.ads-software.com/reference/functions/remove_image_size/ and then re-insert it with add_image_size. Example:

    function child_theme_setup() {
     remove_image_size( 'streamtube-image-medium' );
     add_image_size( 'streamtube-image-medium', 350, 200, true );
    }
    add_action( 'after_setup_theme', 'child_theme_setup', 20 );

    You must enter this code in your own child theme OR use the code snippet plugin. You can find more information about child themes here: https://developer.www.ads-software.com/themes/advanced-topics/child-themes/

    To explain: your idea of changing part of the code is not necessary with WordPress. You can use the above-mentioned hooks to change existing settings and processes. In the add_action() hook I mentioned, the priority is set to 20 so that it is executed after the code from your theme – there is add_action without any priority specification, which then corresponds to the value 10. The higher the priority, the later it is executed.

    Thread Starter kareswebdesign

    (@kareswebdesign)

    Hi there, I searched for the editor function but did not find one.

    Thank you very much! Now I understand it much better and its working like a charme. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Override contenct of functions.php in child theme’ is closed to new replies.