Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_post_data(){
- // Switch based on region
- switch($_REQUEST['region']) {
- //Asia
- case 'China':
- case 'Japan':
- class Post{
- function get_post(){
- global $more;
- $more = 0;
- query_posts('p=122');
- if(have_posts()) : while(have_posts()) : the_post();
- the_title( '<h2>', '</h2>' );
- the_post_thumbnail('medium');
- the_content( '<p>', '</p>' );
- endwhile;
- endif;
- wp_reset_query();
- }
- }
- break;
- //Middle East
- case 'Pakistan':
- case 'Afghanistan':
- class Post{
- function get_post(){
- global $more;
- $more = 0;
- query_posts('p=123');
- if(have_posts()) : while(have_posts()) : the_post();
- the_title( '<h2>', '</h2>' );
- the_post_thumbnail('medium');
- the_content( '<p>', '</p>' );
- endwhile;
- endif;
- wp_reset_query();
- }
- }
- break;
- //etc
- }
- $post = new Post();
- $post->get_post();
- echo json_encode($post);
- die();
- }
- add_action('wp_ajax_get_post_data', 'get_post_data');
- add_action('wp_ajax_nopriv_get_post_data', 'get_post_data');
- ?>
- onRegionClick: function(element, code, region)
- {
- $.ajax(get_data.ajaxurl, {
- data: {region: region, 'action': 'get_post_data'},
- dataType: 'json',
- success: function(response) {
- $("#post").html(response);
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement