Pass parameters to location.href in javascript instead if HEADER()

I am new to wordpress.

I have tried the following code

Read More
    header("Location: $location", true, $status);

I want to redirect the page to particular page and i am getting this kind of error

    "Cannot modify header information - headers already sent by (output started at   /home/content/c/l/a/clareb23/html/client4/wp-content/plugins/featured-articles-lite/main.php:773) in /home/content/c/l/a/clareb23/html/client4/wp-includes/pluggable.php on line 870"

Any suggestions would be appreciated.

Related posts

Leave a Reply

1 comment

  1. Based on comment

    You can do it like this:

    <script>
      window.location = '<?php echo $location?>?myvar=true&status=<?php echo $status?>';
    </script>
    

    Make sure that you do not echo/print anything on screen before header(...) statement and that there is no whitespace before opening php tag eg <?php. It is also good practice to put exit() after header() function.