Advertisement
Guest User

Untitled

a guest
May 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.92 KB | None | 0 0
  1. <?
  2.  
  3. /*
  4. * Template Name: Save Cache
  5. */
  6.  
  7. get_header();
  8.  
  9. $featured_cars = array();
  10. $cars_plates = array();
  11. $featured_phones_nos = array();
  12. $featured_boats = array();
  13. $featured_bikes = array();
  14.  
  15. // Featured Cars
  16. query_listings(array('product_type'=>'cars', 'listings_per_page'=>'4', 'order'=>'rand'));
  17.  
  18. $i = 0;
  19.  
  20. while(have_listings())
  21. {
  22. $featured_cars[$i]["title"] = listing_title(true);
  23. $featured_cars[$i]["permalink"] = listing_permalink(true);
  24. $featured_cars[$i]["image_url"] = listing_thumb(true);
  25. $featured_cars[$i]["photos_count"] = count(listing_photos());
  26. $featured_cars[$i]["year"] = listing_fields('year', true);
  27. $featured_cars[$i]["mileage"] = listing_fields('mileage', true);
  28. $featured_cars[$i]["exterior"] = listing_fields('exterior', true);
  29. $featured_cars[$i]["location"] = listing_fields('location', true);
  30. $featured_cars[$i]["price"] = listing_price(true);
  31. $i++;
  32. }
  33.  
  34. // Featured Car Plates
  35. query_listings(array('product_type'=>'cars_plates', 'listings_per_page'=>'5', 'order'=>'rand'));
  36.  
  37. $i = 0;
  38.  
  39. while(have_listings())
  40. {
  41. $cars_plates[$i]["title"] = listing_title(true);
  42. $cars_plates[$i]["permalink"] = listing_permalink(true);
  43. $cars_plates[$i]["price"] = listing_price(true);
  44. $cars_plates[$i]["expiry"] = listing_expiry(true);
  45. $cars_plates[$i]["format"] = htmlentities(listing_format(true));
  46. $i++;
  47. }
  48.  
  49.  
  50. // Featured Phone Numbers
  51. query_listings(array('product_type'=>'phones_nos', 'listings_per_page'=>'5', 'order'=>'rand'));
  52.  
  53. $i = 0;
  54.  
  55. while(have_listings())
  56. {
  57. $featured_phones_nos[$i]["title"] = listing_title(true);
  58. $featured_phones_nos[$i]["permalink"] = listing_permalink(true);
  59. $featured_phones_nos[$i]["price"] = listing_price(true);
  60. $featured_phones_nos[$i]["expiry"] = listing_expiry(true);
  61. $featured_phones_nos[$i]["operator"] = listing_fields('operator', true, 'value_raw');
  62. $featured_phones_nos[$i]["code"] = listing_fields('code', true);
  63. $featured_phones_nos[$i]["number"] = listing_fields('number', true);
  64. $featured_phones_nos[$i]["format"] = htmlentities(listing_format(true));
  65. $i++;
  66. }
  67.  
  68. // Featured Boats
  69. query_listings(array('product_type'=>'boats', 'listings_per_page'=>'4', 'order'=>'rand'));
  70.  
  71. $i = 0;
  72.  
  73. while(have_listings())
  74. {
  75. $featured_boats[$i]["title"] = listing_title(true);
  76. $featured_boats[$i]["permalink"] = listing_permalink(true);
  77. $featured_boats[$i]["image_url"] = listing_thumb(true);
  78. $featured_boats[$i]["photos_count"] = count(listing_photos());
  79. $featured_boats[$i]["price"] = listing_price(true);
  80. $featured_boats[$i]["type"] = listing_fields('type', true);
  81. $featured_boats[$i]["enginehours"] = listing_fields('enginehours', true);
  82. $featured_boats[$i]["length"] = listing_fields('length', true);
  83. $featured_boats[$i]["location"] = listing_fields('location', true);
  84. $i++;
  85. }
  86.  
  87. // Featured Bikes
  88. query_listings(array('product_type'=>'bikes', 'listings_per_page'=>'4', 'order'=>'rand'));
  89.  
  90. $i = 0;
  91.  
  92. while(have_listings())
  93. {
  94. $featured_bikes[$i]["title"] = listing_title(true);
  95. $featured_bikes[$i]["permalink"] = listing_permalink(true);
  96. $featured_bikes[$i]["image_url"] = listing_thumb(true);
  97. $featured_bikes[$i]["photos_count"] = count(listing_photos());
  98. $featured_bikes[$i]["price"] = listing_price(true);
  99. $featured_bikes[$i]["make"] = listing_fields('make', true);
  100. $featured_bikes[$i]["mileage"] = listing_fields('mileage', true);
  101. $featured_bikes[$i]["exterior"] = listing_fields('exterior', true);
  102. $featured_bikes[$i]["location"] = listing_fields('location', true);
  103. $i++;
  104. }
  105.  
  106. // Save the data in the files
  107. SaveHomeCache("featured_cars.json", $featured_cars);
  108. SaveHomeCache("cars_plates.json", $cars_plates);
  109. SaveHomeCache("featured_phones_nos.json", $featured_phones_nos);
  110. SaveHomeCache("featured_boats.json", $featured_boats);
  111. SaveHomeCache("featured_bikes.json", $featured_bikes);
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement