Support » Theme: Twenty Seventeen » How to change ‘content_width’ in child-theme via functions.php

  • Resolved Michael L.


    I think I found the official filter function that should be the solution on this page. But it doesn’t work!

    function childtheme_content_width( $content_width ) {
        $content_width = 960;
        return $content_width;
    add_filter( 'twentyseventeen_content_width', 'childtheme_content_width' );

    Is there someone who has already had this problem and may have found a solution?
    (A change of the theme is not the solution.)

    Why do I need this?
    For a newsletter via plugin I need an image width of 580px. The maximum image width is set to 525px by content_width in the functions.php. Therefore, max. 525px large images are created in the media library.

    Thank you for your help!

Viewing 5 replies - 1 through 5 (of 5 total)
  • Here is my way:
    in your style.css of (your Child theme), add this code:

    .wrap {
    max-width: 1260px;
    .has-sidebar:not(.error404) #primary {
    float: left;
    width: 68%;

    .has-sidebar #secondary {
    float: right;
    padding-top: 0;
    width: 26%;
    .single-post:not(.has-sidebar) #primary, #primary, .page-header, #primary {
    margin-left: auto;
    margin-right: auto;
    max-width: 1000px;
    .page-one-column .panel-content .wrap {
    max-width: 1000px;

    This works for me:

    add_action( ‘after_setup_theme’, ‘prima_twentyseventeen_setup’,11 );
    function prima_twentyseventeen_setup() {
    $GLOBALS[‘content_width’] = 700;

    It’s, however, important to use a priority >10 to be fired AFTER the twentyseventeen function.

    br Heinz

    • This reply was modified 3 years, 11 months ago by wp_hela.
    Thread Starter Michael L.


    Hi @mezhouwf,

    thank you for your suggested solution!

    But as I described in my last paragraph, I need a functional change of content_width via function.php to be able to generate larger images (>525px) for the media library.
    Unfortunately, CSS does not help in this case.

    Thread Starter Michael L.


    Hello Heinz (@wp_hela),

    I’m shocked there’s a definitive solution! 🤟 Thank You very much!

    This is the working version with straight single quotes:
    ‘add_action( ‘after_setup_theme’, ‘prima_twentyseventeen_setup’,11 );
    function prima_twentyseventeen_setup() {
    $GLOBALS[‘content_width’] = 700;

    Finally I can sleep peacefully again.

    • This reply was modified 3 years, 11 months ago by Michael L..


    You are welcome 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to change ‘content_width’ in child-theme via functions.php’ is closed to new replies.