Hi, documtentation says that php should run in code-blocl elements, but it doesnt.
Its about this code:
<form role=”search” method=”get” class=”search-form”
action=”<?php echo site_url( ‘search-results/’ ); ?>”>
<label>
<span class=”screen-reader-text”>
<?php echo _x( ‘Search for:’, ‘label’ ) ?>
</span>
<input type=”search” class=”search-field”
name=”searchwp”
placeholder=”<?php echo esc_attr_x( ‘Search…’, ‘placeholder’ ) ?>”
value=”<?php echo isset( $_GET[‘searchwp’] ) ? esc_attr( $_GET[‘searchwp’] ) : ” ?>”
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>
You can see the result at the URL I posted in the private area.
Why isn’t it running?
Thanks for supporting!
Hey slikslok,
Thank you for the inquiry.
You can only add html tags or shortcodes in the code block element, PHP codes will not run there. To add PHP snippets, you can use plugins like the ones below.
// https://wordpress.org/plugins/insert-php-code-snippet/
// https://wordpress.org/plugins/code-snippets/
Or directly add them in the functions.php file.
Best regards,
Ismael