Advertisement
Guest User

Untitled

a guest
Sep 20th, 2014
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. function get_post_data(){
  2.  
  3. // Switch based on region
  4. switch($_REQUEST['region']) {
  5. //Asia
  6. case 'China':
  7. case 'Japan':
  8. class Post{
  9. function get_post(){
  10. global $more;
  11. $more = 0;
  12. query_posts('p=122');
  13. if(have_posts()) : while(have_posts()) : the_post();
  14. the_title( '<h2>', '</h2>' );
  15. the_post_thumbnail('medium');
  16. the_content( '<p>', '</p>' );
  17. endwhile;
  18. endif;
  19. wp_reset_query();
  20. }
  21. }
  22. break;
  23.  
  24. //Middle East
  25. case 'Pakistan':
  26. case 'Afghanistan':
  27. class Post{
  28. function get_post(){
  29. global $more;
  30. $more = 0;
  31. query_posts('p=123');
  32. if(have_posts()) : while(have_posts()) : the_post();
  33. the_title( '<h2>', '</h2>' );
  34. the_post_thumbnail('medium');
  35. the_content( '<p>', '</p>' );
  36. endwhile;
  37. endif;
  38. wp_reset_query();
  39. }
  40. }
  41. break;
  42. //etc
  43. }
  44.  
  45. $post = new Post();
  46. $post->get_post();
  47. echo json_encode($post);
  48. die();
  49. }
  50.  
  51. add_action('wp_ajax_get_post_data', 'get_post_data');
  52. add_action('wp_ajax_nopriv_get_post_data', 'get_post_data');
  53. ?>
  54.  
  55. onRegionClick: function(element, code, region)
  56. {
  57. $.ajax(get_data.ajaxurl, {
  58. data: {region: region, 'action': 'get_post_data'},
  59. dataType: 'json',
  60. success: function(response) {
  61. $("#post").html(response);
  62. }
  63. });
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement