-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.php
More file actions
50 lines (45 loc) · 1.08 KB
/
json.php
File metadata and controls
50 lines (45 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Template Name: JSON
*
* Template for showing BLOG category posts that are using ACF Gallery field.
*
* The "Template Name:" bit above allows this to be selectable
* from a dropdown menu on the edit page screen.
*
* @package WordPress
* @subpackage Boilerplate
* @since Boilerplate 1.0
*/
header("Content-Type: text/json");
?>
var data [
<?php
global $post;
$myposts = get_posts();
foreach($myposts as $post){
$id = get_the_ID();
$title = get_the_title();
$content = get_the_content();
$images = get_field('images');
$image = $images[0];
?>
{ image:'<?php echo $image['sizes']['large']; ?>'},
<?php } ?>
]
var data = [
<?php
global $post;
$myposts = get_posts();
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php
$images = get_field('images');
$image = $images[0];
?>
<?php $image_text = array(); ?>
<?php foreach( $images as $image ): ?>
<?php $image_text[] = "{ image :'". $image['sizes']['large'] . "', thumb: '". $image['sizes']['thumbnail'] ."'}"; ?>
<?php endforeach; ?>
<?php echo implode( $image_text, ","); ?>
<?php endwhile; endif; ?>
];