Tag Info

Hot answers tagged

11

I recently got this working. You should search and replace metaname with your meta box name. The key to maintaining formatting was using wpautop(); when saving the data. add_action( 'add_meta_boxes', 'add_metaname_box'); add_action( 'save_post', 'metaname_save'); function add_metaname_box() { add_meta_box( 'metaname_id', __( 'metaname ...


4

Here's (a pared-down version of) what I use to custom-configure TinyMCE: // http://tinymce.moxiecode.com/wiki.php/Configuration function cbnet_tinymce_config( $init ) { // Don't remove line breaks $init['remove_linebreaks'] = false; // Pass $init back to WordPress return $init; } add_filter('tiny_mce_before_init', 'cbnet_tinymce_config'); ...


4

Alright so I've already updated this question a ton and it's starting to get overloaded, so I figured I'd write this as an answer even though it isn't a full one. Extrapolating from @bueltge's answer, I actually went back and found his previous post in question. In that post, there was a plugin listed that I've never seen before: "Preserved HTML Editor ...


4

If this is how it looks: <img class="alignleft size-medium wp-image-8530" alt="..." src="#" width="413" height="275" /> <img class="alignleft size-medium wp-image-8529" alt="..." src="#" width="413" height="275" /> Then you have to put them together like this: <img class="alignleft size-medium wp-image-8530" alt="..." src="#" width="413" ...


3

At first, I think this problem was solved since WP version 3.5; see ticket 19666 in trac. But the tinyMCE have a hook there give us the chance to change the content inside the editor and you must not parse on output on frontend. A small source script. I have no test this with a current WP version, was a older solution for a customer. Add this source via ...


3

Add to function.php add_filter('tiny_mce_before_init', 'tiny_mce_before_init'); And function tiny_mce_before_init: function tiny_mce_before_init($init) { $init['setup'] = "function(ed) { ed.onBeforeSetContent.add(function(ed, o) { if ( o.content.indexOf('<pre') != -1) { o.content = ...


3

Try using get_the_content(); in your page template loop instead of the_content(); EDIT 05/24/2012 - Try this: <div id="main-content"> <?php while( have_posts() ) : the_post() ?> <h1 id="pagetitle"><?php the_title(); ?></h1> <div class="pagecontent"> <?php echo get_the_content(); ?> ...


2

It was a bug in wpautop() which treated <input> as a block element. It is fixed now. See ticket #16456.


2

I have done extended research and found the answer - I am now using a hook on 'tiny_mce_before_init'. Based on other answers (special thanks to answer #2 @Chip Bennett), I have used the following code in my functions.php to secure the paragraph breaks (in the editor HTML mode they show as &nbsp but become paragraphs on the front-end): function ...


2

Figured it out, hooking into content_save_pre: function remove_empty_lines( $content ){ // replace empty lines $content = preg_replace("/&nbsp;/", "", $content); return $content; } add_action('content_save_pre', 'remove_empty_lines');


1

We can not hook wpautop() function. Because then it will trim all the paragraph and break tags from the content. After inserting the image in the editor just click on "Text" tab on the top right corner of the editor and remove the paragraph and break tags that comes in between images. For more options(like alignment and other attributes) click on the ...


1

This should do the trick: remove_filter('the_content', 'wpautop'); remove_filter('the_content', 'wptexturize');


1

There is no filter that would allow you to set allowable tags not to be removed by the_excerpt(). Arguably a shortcoming of the core. Anyhow, the actual excerpt generation does not happen in that template tag but entirely elsewhere: Excerpts are generated by the function wp_trim_excerpt(), inside of which the excerpt filters you are already using ...


1

For what it's worth, this has been fixed in 3.4: http://core.trac.wordpress.org/ticket/18311


1

Found perhaps a simpler workaround for this: on the actual template, change this: <?php echo get_the_content());?> to this: <?php echo wpautop(get_the_content());?> This way wpautop() adds the tags stripped out by TinyMCE on a template by template basis.


1

you could also say that TinyMCE is integrated with WordPress and the HTML editor strips out some characters in favour &nbsp ... this was originally for security and the belief that we didnt need <br> or <p> anymore


1

why not you use wordpress new function wp_editor to render the tinymce. That way everything will get handled. And when you show the content to the user apply the filter the_content. Like this: $meta = "content of the metabox"; echo apply_filters('the_content', $meta); The filter the_content will autmatically convert the link brakes to <br> and ...


1

It's working for me -- have you checked your source code on the published post to see if <br> tags are being inserted? If so, you may want to check your CSS to make sure nothing is over-riding the tags. One of the biggest culprits can be float: left being applied to the line breaks.


1

The editor is doing fine to add <p> tag on line break. I think what you need is to add some css to add margin to <p> tag so you don't have to add additional or empty paragraph tags (which i see on your current page). try something like this on your css: .entry-content p{ margin: 10px 0; } That should give you a nice margin on top and ...


1

I have also added custom shortcodes to functions.php to avoid things breaking when switching from html to visual editors. Mainly I've used this for iFrame's, but maybe it would be helpful here too.


1

First things first, modifying core files is extremely frowned upon you will have to make these changes with every upgrade and they can lead to security and other problems. I'm pretty sure there is a plugin that will allow this. I did a simple search and here are a few to try: http://wordpress.org/extend/plugins/preserved-html-editor-markup/ ...


1

You are correct that it is the <br> tags, but there is an alternative: Place each image in their own paragraph, not adjacent lines This is how line breaking works in WordPress content: Paragraphs This is paragraph 1 This is paragraph 2 Short line breaks This is paragraph 1 This is also paragraph 1 but on a new line without a space So don't ...


1

The quick fix is to wrap your image tags in div tags. That will prevent WP from wrapping the images in P tags. Then, you could give the divs a class for further control of appearance/arrangement.



Only top voted, non community-wiki answers of a minimum length are eligible