php-wordpressHow to add a PHP header in WordPress?
Adding a PHP header in WordPress is a simple process. To do this, you need to use the header() function. This function takes two parameters: the header name and the header value.
<?php
header("Content-Type: text/html; charset=utf-8");
?>
This code will add a header with the name Content-Type and the value text/html; charset=utf-8.
Code explanation
<?php- This is the opening PHP tag.header()- This is the function used to add a header."Content-Type"- This is the header name."text/html; charset=utf-8"- This is the header value.?>- This is the closing PHP tag.
Helpful links
More of Php Wordpress
- How to use body_class() in WordPress with PHP?
- How to disable PHP warnings in WordPress?
- How to redirect to another page in WordPress using PHP?
- How to check the PHP version in WordPress?
- How to use hooks in WordPress with an example?
- How to configure Nginx for WordPress?
- How to create a menu in WordPress using PHP?
- How to use get_header in WordPress using PHP?
- How to use the WordPress REST API with PHP?
- How to get the current URL in WordPress using PHP?
See more codes...