从wordpress重定向到Instagram授权URL

I'm making a Divi theme module that's gonna display user's Instagram feed on a page. I need to redirect them to Instagram authorization URL. The divi module is a PHP file.

PHP function header() isn't working: Warning:

Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\wp-includes\class.wp-styles.php:237) in C:\xampp\htdocs\test\wp-content\themes\Divi-child\Modules\Instagram\init.php on line 21

What different way can I use to redirect a user to this URL or am I approaching this all wrong.

You can use:

?>
<script type="text/javascript">
window.location.href = 'your_url';
</script>
<?php

or:

echo "<script>window.location.href='your_url'</script>";

And at last:

$url = "your_url";
echo '<meta HTTP-EQUIV="refresh" content="0;URL=' . $url . '">';

Where 0 is the number of seconds.