Using variable passed in URL
-
I’m able to pass a variable in a url like so:
https://mysite.com/?searchterm=544
.. and I am able to GET the variable and display it in a php echo like so (this is placed before the loop):
<?php $searchterm = $_GET["searchterm"]; ?> Search term: <?php echo $searchterm; ?>
BUT if I insert the echo in the query_post like so:
<?php query_posts('p=<?php echo $searchterm; ?>'); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
… it doesn’t seem to work correctly, but if I manually enter 544 in place of the echo it works as expected.
Any ideas!? Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Using variable passed in URL’ is closed to new replies.