Domanda

im still trying to fix my site, to display content according to the parameters in the URL, I have managed to change links and other parameters, but when it comes to choosing a correct header im lost.

This was the original code

<?php
/*
Template Name Posts: Post Template
*/

include (TEMPLATEPATH . '/header3.php'); ?>

And this worked well, now I tried to change header regarding the url parameter with such code

<?php
if (isset($_GET['ad']) && $_GET['ad'] == 1)
{
echo include (TEMPLATEPATH . '/header3.php');
}
else {
echo include (TEMPLATEPATH . '/header4.php');
}
?>

All works fine and the other header does show when parameter is present in URL, but problem is that it now prints

"1"

onto the page when I load it. I can see the modified header, but as soon as the header ends, it shows number one in main div, although there isnt such number in code. When I reverted back to the original code, then the problem was gone. Also this problem does not exist when I use modified header, with original code.

Problem is somehow connected with the parameter and then loading the correct header. Im using wordpress and need to get a special header when URL has a specific code in it.

È stato utile?

Soluzione

change:

 echo include (TEMPLATEPATH . '/header3.php');

to:

include (TEMPLATEPATH . '/header3.php');

you need not to echong include. remove all echos then it should not be echoing 1.
see basic include doc

Altri suggerimenti

since you've echo include(), so this will display the response, which in your case is 1 for true, as your file is included...Simply remove the echo and include as :

 include(TEMPLATEPATH . '/header3.php')
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top