How do I turn off self-closing tags for markup in WordPress (for HTML5, or HTML4, for example)?

I want to use HTML5 in my WordPress theme, how do I turn off wptexturize? I don't mind WP adding breaks, but I want them to be <br> and not <br />. How do I get control over how those breaks show up in my code? EDIT: I only really care about the <br> tag issue, I don't mind the typographic changes it makes. EDIT2: Actually, I guess <img> tags matter too. Any self-closing standalone tags will matter here. So, …
Category: Web

wp_nav_menu returns menu list in ascending order. How can I arrange the menu same as dashboard menu

<?php wp_nav_menu(array( 'theme_location' => 'primary', 'container' => 'ul', 'menu_class'=> 'top-menu' /* 'walker' => new Walker_nav_Primary() */ ) ); ?> This is a simple wp_nav_menu You can see ascending order from above example I have done this in WP. wp_nav_menu gives me ascending order menu. How can I arrange as dashboard? Please help.
Category: Web

How to make Wordpress and TinyMCE accept <a> tags wrapping block-level elements as allowed in HTML5?

Starting with version 5 the HTML standard allows &lt;a&gt; tags wrap block-level elements. On a specific page I need to wrap a heading and an image with an &lt;a&gt; tag: Some intro text. &lt;div&gt; &lt;a href="http://somewhere/"&gt; &lt;h4&gt;Some heading&lt;/h4&gt; &lt;img src="http://somewhere/some-img.jpg" alt="Some image" /&gt; &lt;/a&gt; &lt;/div&gt; While I can enter this in the text editor it causes some strange behavior: The code above will be transformed into this HTML code: &lt;p&gt;Some intro text.&lt;/p&gt; &lt;div&gt; &lt;a href="http://somewhere/"&gt;&lt;/p&gt; &lt;h4&gt;Some heading&lt;/h4&gt; &lt;p&gt;&lt;img src="http://somewhere/some-img.jpg" alt="Some …
Category: Web

TinyMCE editor is breaking my beautiful HTML

This is pretty much an exact duplicate of: How to make Wordpress and TinyMCE accept &lt;a&gt; tags wrapping block-level elements as allowed in HTML5? and HTML5, WordPress and Tiny MCE issue - wrapping anchor tag around div results in funky output My problem is that the suggested solution (tiny_mce_before_init filter) doesn't seem to solve my problem. I have HTML that looks like this: &lt;a href="#"&gt; &lt;img src="path/to/file.jpg" /&gt; &lt;p&gt;Some amazing descriptive text&lt;/p&gt; &lt;/a&gt; The is perfectly legal in HTML5. However, …
Category: Web

how to check if an element in an html file exists in another html file?

Imagine that I have an HTML file as one of my WordPress blog pages (let's call it page B). I want to write an if condition inside a tag on page B to check if a specific element exists on another web page (page A). My question is what function should I choose to check this condition? Should I also import the HTML file of page A inside page B? And what should I do on the server-side, if I …
Category: Web

How do I use <picture> element instead of <img> tags in WordPress post content having webP support?

I am developing my custom theme and trying to figure out how to modify the default code for WordPress image inserted into the post content, so I could add support for webP format and have it within &lt;picture&gt; element. I generate .webp images using cwebp library on my server and PHP exec() while image upload to the Media in WordPress Admin. The code is: function my_image_webp($meta, $id){ if(!isset($meta['sizes'])) { return $meta['full']; } $upload_path = wp_upload_dir(); $path = $upload_path['basedir']; // media …
Category: Web

Why does `add_theme_support( 'html5', array( 'comment-form' )` disable client side validation?

In order to use HTML5 markup for the comment forms, I add the following code snippet to functions.php: add_theme_support( 'html5', array( 'comment-form' ) ); However, it disables client side validation on form submit and I get redirected to an error page: Now, if I remove add_theme_support( 'html5', array( 'comment-form' ) ); and submit the comment form, I get client side validation: Can anybody explain why this is? Is it a bug? Or expected behavior? I am currently using WordPress 4.7.
Category: Web

ACF Wysiwyg Editor Image srcset for responsive images

I cannot find a way to generate srcset for images added inside Wysiwyg Editor field of Advanced Custom Field (ACF) plugin. Obviously, i know how to generate WordPress image srcset using: wp_get_attachment_image_srcset($attachment_id); function, as described at WordPress codex: https://developer.wordpress.org/reference/functions/wp_get_attachment_image_srcset/ But my real problem is to figure out most efficient way to get image srcset for images added inside ACF Wysiwyg Editor as the way my website is structured there is too much content inside my Wysiwyg Editor like text, images, …
Category: Web

Using HTML 5 Details/Summary Tag

I just wanted to use the details/summary tag on my webpage. Using the summary tag, I'm able to define what my caption looks like. BUT, as soon as I want to edit the page in the visual editor, wordpress removes the summary tag and the standard 'Details' is shown. Is that a bug, or am I doing anything wrong?
Category: Web

Remove frameborder attribute from iframes

The W3C Validator outputs an error because Wordpress adds frameborder="0" to iframes. Also the Validator does not like the allow attribute. I found a similar question for Vimeo Videos: WordPress oEmbed W3C Validation. However, I couldn't get it to work. That's the code I added to the function.php file which however does not work: add_filter( 'oembed_dataparse', function( $return, $data, $url ) { if( is_object( $data ) ) { // Remove the unwanted attributes: $return = str_ireplace( array( 'frameborder="0"' ), '', …
Category: Web

Adding <aside> to the WYSIWYG

I'm trying to add the &lt;aside&gt; tag to the WYSIWYG, just like you can add a blockquote. (Basically have a button to wrap the element in an &lt;aside&gt; tag) I can't seem to find out how to add it by programming means, and things like the plugin Advanced TinyMCE doesn't seem to contain the option. So how can I add a custom tag to the WYSIWYG?
Category: Web

From php web to wordpress conversion, href changes only in URL

I have converted my PHP dynamic website into WordPress. Whole design is perfect. But unfortunately, when I click on any href link. it just changes in URL but not displaying the related linked page. Following images clarify more good: When Clicking on link addDegree.php From sidebar nav: &lt;li class="nav-item" data-toggle="tooltip" data-placement="right" title="Degree Pages"&gt; &lt;a class="nav-link nav-link-collapse collapsed" data-toggle="collapse" href="#collapseDegreePages" data-parent="#exampleAccordion"&gt; &lt;i class="fa fa-graduation-cap" style="color:gray;"&gt;&lt;/i&gt; &lt;span class="nav-link-text"&gt;Degree Management&lt;/span&gt; &lt;/a&gt; &lt;ul class="sidenav-second-level collapse" id="collapseDegreePages"&gt; &lt;li&gt; &lt;a href="addDegree.php"&gt;Add New Degree&lt;/a&gt; &lt;/li&gt; &lt;li&gt; &lt;a …
Category: Web

Ajax request with jQuery without WP_ajax

I try to made a website in full ajax (a html5 website). I use jquery and innerShiv (for ie). For exemple I want to load all the content of the "section" tag of a page. When I use that script, it works perfectly : var link = 'http://ajax.wuiwui.net'; $('#new').load(link + ' #contenu'); But when i use this one, I can't find element which aren't into the wordpress loop... $.ajax({ url: link, processData: false, success: function(data){ data = innerShiv(data,false); var truc …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.