Question

I'm kind of new to creating my own themes with WordPress 4.x so I hope it's not too boring.

In search.php I'm using this code:

get_search_form ()

Also, I got this code in searchform.php

<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
    <label>
        <span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span>
        <input type="search" class="search-field"
            placeholder="<?php echo esc_attr_x( 'Search …', 'placeholder' ) ?>"
            value="<?php echo get_search_query() ?>" name="s"
            title="<?php echo esc_attr_x( 'Search for:', 'label' ) ?>" />
    </label>
    <input type="submit" class="search-submit"
        value="<?php echo esc_attr_x( 'Search', 'submit button' ) ?>" />
</form>

If i'm getting this right, on the Wordpress Developers website, where I got the codes from... it also says to add a code with a function to support HTML5 which looks like this:

function wpdocs_after_setup_theme() {
    add_theme_support( 'html5', array( 'search-form' ) );
}
add_action( 'after_setup_theme', 'wpdocs_after_setup_theme' );

Now, after testing it for a few seconds, everything looks working fine without this HTML5 support function... but I don't understand if I should add it to my functions.php file anyway?!

My code in functions.php looks like this:

function customTheme_setup() {
    // Thumbnails support
    add_theme_support('post-thumbnails');
}
add_action('after_setup_theme', 'customTheme_setup');

I'm using WordPress 4.4.2 and the theme is crafted from scratch. so, I don't have the code in there to support HTML5... but, since I already got a function to use after theme setup with another code for the image...

should I add the function, anyway? If so, how the code should look like, together with the function for the image support line?

Was it helpful?

Solution

You can add HTML5 support which will be very useful. I will consider that you won't be testing your new wordpress theme on all the real devices due to which you should add HTML5 support in functions.php. You can frame the code as below:

function customTheme_setup() {
    // HTML support
    add_theme_support( 'html5', array( 'search-form' ) );
    // Thumbnails support
    add_theme_support('post-thumbnails');
}
add_action('after_setup_theme', 'customTheme_setup');

Please let me know, if you have any query.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top