How to show the contants in front end same as visual editor with space / linebreak?

When you use get_the_content() to get your content, you need to apply filters to it to output with formatting. apply_filters(‘the_content’, $content); If you don’t need to do anything with the content before outputting it, you can replace your line $content = get_the_content(‘Read more); print $content; with just the_content(); For reference see apply_filters() and get_the_content() in … Read more

Why exactly does WordPress use p tags, not divs?

You should simply not use <div>-elements to seperate paragraphs from each other. It´s wrong in the semantical context, I think. When you press “Enter” you make, from a historical point of view, a “carriage return” and then a “line feed”. You start a new line, maybe a new paragraph but nothing completely new. If you … Read more

How can a TinyMCE modal return formatted/visual text?

(Revised answer) You can use tinymce.DOM.encode() to convert all HTML tags to their entities, e.g. &lt; for < and &gt; for >: var html = tinymce.DOM.encode(e.data.code); Then to preserve trailing white-spaces: html = html.replace(/(^ +| +$)/gm, function(match, p1){ return p1.replace(/ /g, ‘&nbsp;’); }); And this to convert all line breaks to <br>: html = html.replace(/(?:\r\n|\r|\n)/g, … Read more

how can default_content filter tell if content will load in block editor or classic editor?

Looks like WP_Screen::is_block_editor() is what you want. Here’s some rough code to demonstrate: add_filter( ‘default_content’, function( $content, $post ) { $screen = function_exists( ‘get_current_screen’ ) ? get_current_screen() : null; $is_block_editor = $screen ? $screen->is_block_editor() : false; if ( $is_block_editor ) { // Do your block editor stuff here } else { // Do your classic … Read more

Can’t give tags rels

function extend_tinymce( $values ) { $elements=”pre[id|class|title|rel]”; if ( isset( $values[‘extended_valid_elements’] ) ) { $values[‘extended_valid_elements’] .= ‘,’ . $elements; } else { $values[‘extended_valid_elements’] = $elements; } return $values; } add_filter(‘tiny_mce_before_init’, ‘extend_tinymce’); The above snippet is what I use for example, of course you can extend this beyond id, class, title, rel, to things such as height, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)