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 send an email using PHP in WordPress?
- How to disable PHP warnings in WordPress?
- How to create a snippet in WordPress using PHP?
- How to get the site URL in WordPress using PHP?
- How to configure Nginx for WordPress?
- How to hide PHP warnings in WordPress?
- How to get post meta in WordPress using PHP?
- How to get categories in WordPress using PHP?
- How to get the post ID in WordPress using PHP?
See more codes...