0

I am trying to understand how add_theme_support() function works, but at the section of Html5 i tried to use it with gallery and i noticed that the markup has changed for it,and here is what i did

add_theme_support( 'html5', array('gallery') );

but for the others like search-form or comment-form for example

add_theme_support( 'html5', array( 'comment-form','search-form','gallery', 'caption' ) );

i didn't notice any change in the output, so Am i missing some thing? or how it works?

1

According to the documentation, you must pass an array of items where you want to enable HTML5 markup:

add_theme_support( 'html5', array(
    // Any or all of these.
    'comment-list', 
    'comment-form',
    'search-form',
    'gallery',
    'caption',
) );

The documentation also recommends using add_theme_support() on the after_setup_theme hook, stating that the init hook may be too late for some features.

Reference

Developer documentation: add_theme_support() » HTML5

  • sorry there is a miss understanding, i will edit my question – Mohamed Omar Sep 6 '17 at 14:24
0

I have figured out why no changes happens, and the problem was that i am calling a custom search form file searchform.php and the function add_theme_support() affects the built in features only. So if you want to use the default search form by calling get_search_form() without having the searchform.php file, then you can use

add_theme_support( 'html5', array( 'search-form' ) );

and this will apply an html5 markup to the form. The following are the before and after add_theme_support()(Contains Arabic Text):

Before:

<form role="search" method="get" id="searchform" class="searchform" action="http://localhost/TB/">
            <div>
                <label class="screen-reader-text" for="s">البحث عن:</label>
                <input value="" name="s" id="s" type="text">
                <input id="searchsubmit" value="بحث" type="submit">
            </div>
        </form>

After:

<form role="search" method="get" class="search-form" action="http://localhost/TB/">
            <label>
                <span class="screen-reader-text">البحث عن:</span>
                <input class="search-field" placeholder="بحث …" value="" name="s" type="search">
            </label>
            <input class="search-submit" value="بحث" type="submit">
        </form>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.