0

I have problem when edit an news in post editor, and set the images from editor align left and open site, i cannot see the image in left said.

How can set the post style from editor not from style

3
  • Maybe the theme you use does not have css definitons for the alignleft class that the added image has.
    – aifrim
    Commented Sep 17, 2014 at 16:15
  • no i add it ,,, any solution Commented Sep 17, 2014 at 18:19
  • Write the code that you added :)
    – aifrim
    Commented Sep 18, 2014 at 6:43

1 Answer 1

0

add_editor_style allows theme developers to link a custom stylesheet file to the TinyMCE visual editor.

You'll want to duplicate many (if not all) of your styles from the front-end to be included in that file. Then editing in the visual editor will look more like your front-end css.

The problem is more likely that you don't have a alignleft class in your front-end stylesheet. wp_print_styles will give you an opportunity to add custom inlined styles.

add_action('wp_print_styles', function() { ?>
<style>
    /**
     * 4.0 - Alignment
     */

    .alignleft {
        float: left !important;
        margin: 6px 28px 28px 0;
    }

    .alignright {
        float: right !important;
        margin: 6px 0 28px 28px;
    }
</style>
<?php
});

If you literally want to put the editor styles on the front-end (which nobody said ever) then just wp_enqueue_scripts.

add_action('wp_enqueue_scripts', function() {
    wp_enqueue_style('editor-styles', includes_url('/css/editor.css'));
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.