• Resolved Mark

    (@markyork)


    I’m using a child of Twentyfourteen on this site (although I’m not sure that the theme being used is relevant in this case).

    The content of the visual editor is being set by this style rule:

    html .mceContentBody {
        font-size: 100%;
        max-width: 474px;
    }

    I followed the answer in this question at StackOverflow WordPress Development: “Why is the visual editor in WordPress limiting the width by wrapping the content?” and put this code in my custom editor stylesheet:

    html .mceContentBody {
        max-width: none !important; }

    I am quite positive I’m correctly enqueuing the custom editor stylesheet (changes I make in style.css work). Here’s what I have in my child functions.php file:

    <?php
    
    function RegisterCustomScriptsStyles(){
      // Register and enqueue custom stylesheets
    
      // Register custom stylesheets to the path to the theme's stylesheets
      wp_register_style( 'customStylesheet', get_template_directory_uri() . '/style.css');
      wp_register_style( 'customEditorStylesheet', get_template_directory_uri() . '/editor-style.css');
    
      // Enqueue the stylesheets
      wp_enqueue_style( 'customStylesheet' );
      wp_enqueue_style( 'customEditorStylesheet' );
    
      // Register and enqueue custom scripts
      // Register custom scripts to the path to the theme's scripts
      //wp_register_script( 'customScript', get_stylesheet_directory_uri() . '/customScript.js', array('jquery') );
      //wp_enqueue_script( 'customScript' );
    } 
    
    add_action('wp_enqueue_scripts', 'RegisterCustomScriptsStyles');

    So what am I missing/doing wrong?

Viewing 4 replies - 1 through 4 (of 4 total)
  • You should use javascript to edit css elements and also add the code to the end of you blog posts or pages…
    Is your website responsive like mine see [Link redacted]
    also the homepage [Link redacted]
    or my other site on [Link redacted]

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    @kingnkv, Thanks for helping out, but can you avoid posting links to your site?

    Moderator bcworkz

    (@bcworkz)

    Since you are modifying admin CSS you should hook ‘admin_enqueue_scripts’ instead of ‘wp_enqueue_scripts’. The docs on this are kinda buried: Function_Reference/wp_enqueue_script#Notes.

    I’m not sure this will solve your problem, but you should do this anyway.

    Thread Starter Mark

    (@markyork)

    Turns out you were close, bcworkz.

    The WP Function Reference page is actually this.

    Here’s the sample code from that page to do what I’m trying to do:

    <?php
    function my_theme_add_editor_styles() {
        add_editor_style( 'custom-editor-style.css' );
    }
    add_action( 'admin_init', 'my_theme_add_editor_styles' );

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Can't change the width of content in the visual editor’ is closed to new replies.