WP Editor strips input placeholder attribute

Why WP Editor also strips the “placeholder” attribute of the input text element ? Ofcourse, i am using the HTML mode. Here is the input: <input type=”text” value=”” name=”s” style=”width: 550px;” placeholder=”Search this website..”> After updating the post (after strip): <input type=”text” value=”” name=”s” style=”width: 550px;”> I do not want WP Editor to strip such … Read more

Preserve white-space in Page

I frequently post pages with code examples. However, WordPress strips out whitespace, thus ruining the indentation and formatting of my code. So this: <pre> selector { property: value; property: value; } </pre> becomes this: selector {property: value;property: value;} I found the Raw HTML plugin, which fixes linebreaks, but even with Raw HTML, the spaces aren’t … Read more

strip only specific tags (like ), but keep other tags (like )

I know it’s easy to disable WordPress from adding both p and br tags with: remove_filter( ‘the_content’, ‘wpautop’ ); remove_filter( ‘the_excerpt’, ‘wpautop’ ); but I want WordPress to keep adding <br> where there is a line break. I only use text editor, visual editor is disabled. It was working fine until the recent update to … Read more

Removing buttons from the html editor

I’ve been searching the codex, and I’m probably overlooking something somewhere, but could someone tell if it would be possible to remove a button/quicktag from the WordPress html editor? 2 Answers 2 With the quicktag_settings filter: function wpa_47010( $qtInit ) { $qtInit[‘buttons’] = ‘strong,em,link,block,del,img,ul,ol,li,code,more,spell,close,fullscreen’; return $qtInit; } add_filter(‘quicktags_settings’, ‘wpa_47010’); The default is: $qtInit[‘buttons’] = ‘strong,em,link,block,del,ins,img,ul,ol,li,code,more,spell,close’; … Read more

Prevent WordPress from adding linebreaks to javascript embedded in a page

On a page in WordPress, If I enter the following code: var r=”<li><a href=”#”><img src=”” + slide.src + ‘” width=”50″ height=”50″ /></a></li>’; it is rendered in the browser as var r=” <li><a href=”#”><img src=”” + slide.src + ‘” width=”50″ height=”50″ /></a></li> ‘; and it gives me this error in FF Console SyntaxError: unterminated string literal … Read more

serialize_blocks breaking html tags in content

I’m trying to inject some data into blocks via PHP but am running into trouble with parse_blocks/serialize_blocks breaking my content I’m using the default 2020 theme and have no plugins installed add_action(‘wp’, function() { $oPost = get_post(119); printf(“<h1>Post Content</h1><p>%s</p>”, var_dump($oPost->post_content)); $aBlocks = parse_blocks($oPost->post_content); printf(“<h1>Parsed Blocks</h1><pre>%s</pre>”, print_r($aBlocks, true)); $sSerialisedBlocks = serialize_blocks($aBlocks); printf(“<h1>Serialised Blocks</h1><p>%s</p>”, var_dump($sSerialisedBlocks)); }, PHP_INT_MAX); … Read more

How to to stop html editor from addig tags to shortcodes, images, etc

I know this this is covered as individual topics but What I am looking for is a single function that stops <p> tags from being wrapped around via the WordPress editor to shortcodes and images and also removes empty <p> tages, for example: remove <p> tags that get wrapped around shortcodes, i.e., <p>[shortcode]</p> remove empty … Read more