Skip to main content
Share Your Experience: Take the 2024 Developer Survey
6 votes
Accepted

How to change the markup Wordpress inserts for post images

As far as I know you could hook into the filter image_send_to_editor like this: function html5_insert_image($html, $id, $caption, $title, $align, $url) { $url = wp_get_attachment_url($id); $...
tillinberlin's user avatar
6 votes
Accepted

Remove frameborder attribute from iframes

WordPress doesn't add the frameborder attribute. YouTube does. It's part of their embed code. If you absolutely must remove it you can use the embed_oembed_html filter to modify the returned HTML: ...
Jacob Peattie's user avatar
4 votes

Make post_content and other custom fields required

Don't rely entirely on JavaScript validations. Use below hook for Server side validation. function check_if_post_content_set( $maybe_empty, $postarr ) { // Check if post is already created. ...
JItendra Rana's user avatar
3 votes
Accepted

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

You have to loop through all images inside $post the_content() using foreach(). Which gives us, regex for group matching of <img> tag. Put all images into array(). Start counting from -1 ...
Ho Thanh Cyberdelia Nhan's user avatar
3 votes

How to add attributes to the comment form tag?

Use this function rather than comment_form() function validate_comment_form(){ ob_start(); comment_form(); echo str_replace('<form','<form attribute="value" ',ob_get_clean()); }
Farhad Sakhaei's user avatar
3 votes
Accepted

how to change Wordpress menu markup/classes

Changing the CSS is the simplest way to apply your desired styles. Another alternative, as Jack mentioned, is to create a custom walker. The Codex has a good overview. The third option is a happy ...
WebElaine's user avatar
  • 9,430
3 votes

How to setup Landing HTML5 page in WordPress site

shove that html into a front-page.php file and add that to your theme via ftp. make a blank page, name it front page (or whatever) and then in settings->reading set the front page to display a static ...
mrben522's user avatar
  • 1,673
3 votes

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

No, it is not a bug. This is how core handles it. If you look into /wp-includes/comment-template.php, you'll notice, that the only difference in <form> element, is novalidate attribute added, ...
Frank P. Walentynowicz's user avatar
2 votes

How to change the markup Wordpress inserts for post images

There's a filter called image_send_to_editor that lets you specify the markup. You will also need wp_get_attachment_metadata to retrieve width and height. It is called like this (untested): ...
cjbj's user avatar
  • 14.6k
2 votes

How to Convert Shortcode into a link?

Wrap your shortcode in a div and give it an ID that you can use as a target when triggering your popup. For example, you can put the shortcode somewhere on your page (content, sidebar, etc) as follows:...
ajie's user avatar
  • 101
2 votes
Accepted

Why is Heading tag Auto applied to Post data?

Your second h4 tag is again an opening tag. This echo '<h4>'.get_the_date().'<h4>'; should be this echo '<h4>'.get_the_date().'</h4>';
M-R's user avatar
  • 2,606
1 vote
Accepted

How to add the sidebar to all the pages except the home page?

I don't know if I understand you correctly, but probably in the file which calls get_sidebar(): You could do something like if ( ! is_home() ) { get_sidebar(); } Or in your header.php where the ...
uruk's user avatar
  • 529
1 vote

Adding custom attributes to input fields in Contact Form 7 tags

You can't as of now add it to the tag, you'll need to add a custom file field in your form such as, <label> Some Text field [text my-text-field] </label> <label> My image capture ...
Aurovrata's user avatar
  • 1,336
1 vote

Using HTML 5 Details/Summary Tag

WordPress filters the markup used in post content as a security measure. This stops people inserting malicious javascript inside comments or posts. On a non-multisite install, administrators ...
Tom J Nowell's user avatar
  • 59.4k
1 vote
Accepted

Adding <aside> to the WYSIWYG

TinyMCE has a 'formats' dropdown that you can add options to: This option enables you to add more advanced style formats for text and other elements to the editor. The value of this option will ...
Jacob Peattie's user avatar
1 vote

difference between sanitize_email ,FILTER_VALIDATE_EMAIL and input email type in html5

1- HTML5 <input type=”email”> Define a field for an e-mail address (will be automatically validated when submitted) Tip: Safari on iPhone recognizes the email type, and changes the on-screen ...
IBRAHIM EZZAT's user avatar
1 vote

Received nothing after executing AJAX post function

Please read the Wordpress tutorial on using AJAX in plugins (you are basically adding a plugin to your theme if you need to use AJAX). There are two things I see right off the bat that need to be ...
scott's user avatar
  • 465
1 vote

How to retain HTML5 Attributes on Markup

It is enough to add unfiltered_html capability to Editor role. Add the following code into your current theme's functions.php: function wpse_change_capability() { $role = get_role( 'editor' ); ...
Frank P. Walentynowicz's user avatar
1 vote

Meta Tag "description"

Do not add meta tags in post editor. Best way to do is use SEO plugins. Best plugin for SEO is Yoast Seo Or add this code in your themes header.php just after title tag. <meta name="description" ...
Rocky Sena's user avatar
1 vote
Accepted

How to output images as figure/figcaption

add_theme_support( 'html5', array( 'gallery' ) ); or with another arguments such as search-form, comment-form, comment-list and caption, its call as Theme Markup Added gallery and caption support was ...
Jevuska's user avatar
  • 1,160

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