Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Template Name: Page No Title
- */
- header('Content-Type: application/json');
- header("Access-Control-Allow-Origin: *");
- $actual_link = "$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
- // args
- $args = array(
- 'numberposts' => -1,
- 'post_type' => 'movie',
- 'meta_key' => 'imdb_id',
- 'meta_value' => preg_replace('/[^0-9]/', '', $actual_link)
- );
- // query
- $the_query = new WP_Query( $args );
- ?>
- <?php if( $the_query->have_posts() ): $json = array();?>
- <?php while( $the_query->have_posts() ) : $the_query->the_post(); ?>
- <?php
- $bus = array(
- 'audio' => get_field('audio'),
- 'quality' => get_field('quality'),
- 'url' => get_field('url')
- );
- array_push($json, $bus);
- ?>
- <?php endwhile; ?>
- <?php endif; ?>
- <?php
- $jsonstring = json_encode($json);
- echo $jsonstring;
- ?>
- <?php wp_reset_query(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement