I'm trying to pass the variables to a new page, I made a function in my theme to get the results. Now when I use yelplist();
on the front page of my theme it gets the results and when i click on the link it passes the image and city back to me as requested.
Questions:
- However I am wondering what i can do to have variables pass to their own page. For example: if I click on the name, a new page comes with the results of an image and a city for that link.
- Also is it possible to have it done in the single.php file, or will it be a completely new page/file?
Update 1
*I've made a little bit of progress using $_SESSIONS, I am now able to pass the variables into the single.php file however, when I click on the link thats suppose to grab the results from the current link it does not update the variables that are in the single.php file, instead its only getting the last parsed link's info instead of the one I am clicking on.
Also when I click on the link at the bottom and make it try to go to the single.php file I get a object not found <a href='single.php?p=$pizza_url'><img border=0 src='".$business->photo_url."'></a>
what can I do to make it go to the single page and update the variables?
this is what I have in my functions file.
function yelplist(){
require_once ('/lib/OAuth.php');
require_once ('yelp.php');
require_once(ABSPATH.'/wp-admin/includes/taxonomy.php');
$yelpstring = file_get_contents('http://api.yelp.com/business_review_search?term=pizza&location=Los%20Angeles&ywsid=xxxxxxxxxxxxxxxxxxx');
$obj = json_decode($yelpstring);
foreach($obj->businesses as $business):
$business->photo_url;
$pizza_name = $business->url;
$business->name;
$business->phone;
$city = $business->city;
$url = ''.$business->url.'';
$pizza = parse_url($url, PHP_URL_PATH);
$pizza_url = trim(''.$pizza.'','/biz');
$lower_case_city_url = $city;
$lower_case_city_url = strtolower($lower_case_city_url);
$city_url = str_replace(' ','-',$lower_case_city_url);
if(isset($_SESSION['p']) && $_SESSION['p']==''.$pizza_url.'') {
$_SESSION['pizza_name']= $business->name;
$_SESSION['pizza_city']= $city = $business->city;
$_SESSION['pizza_phone']= $business->phone;
$_SESSION['pizza_photo'] = $business->photo_url;
}else{
echo "<div><a href='?p=$pizza_url'>$business->name</a></div>";
}
endforeach;
}
this is what im using in the single.php file to grab the results.
<?php session_start(); ?>
<?php echo $_SESSION['pizza_name']; ?> </br>
<?php echo $_SESSION['pizza_phone']; ?></br>
<?php echo $_SESSION['pizza_city']; ?></br>
<?php echo "<img border=0 src=".$_SESSION['pizzaphoto'].">"; ?>
Thanks