@ 2017-07-07T20:49:57Z <?php
<?php
/*
Template Name: Timeline JS 3 JSON page
Description: Outputs the list Timeline Entries as JSON
*/
header('Content-type: application/json');
$args2 = array("category_name" => "timeline", "posts_per_page" => -1, "orderby" => "title", "order" => "ASC");
$query = new WP_Query( $args2 );
$posts = $query->posts;
$output = array();
$main_title = array();
$main_events = array();
$main_title_text = array("headline" => "Tibetannewspapers Timeline", "text" => "" );
$main_title = array("text" => $main_title_text );
foreach ($posts as post ){
$the_date_start = get_field("start_date", $post->ID);
$the_date_start_alternative = date("Y,m,d",strtotime($post->post_date));
$the_date_end = get_field("end_date", $post->ID);
if ($the_date_start == "") {
$the_date_start = $the_date_start_alternative;
}
if ($the_date_end =="") {
$the_date_end = $the_date_start;
}
$startdate=array();
$startdate = array("year" => substr($the_date_start, 0, 4) ,month" => substr($the_date_start, 4, 2), "day" => substr($the_date_start, 6, 2));
$enddate=array();
$enddate = array("year" => substr($the_date_end, 0, 4) ,month" => substr($the_date_end, 4, 2), "day" => substr($the_date_end, 6, 2));
$media=array();
if( has_post_thumbnail( $post->ID) )
{
$caption = get_post( get_post_thumbnail_id() )->post_excerpt;
$mediaurl = get_the_post_thumbnail_url( $post->ID, 'full' ) ;
$media=array("url" => $mediaurl, "credit" => "", "caption" => $caption);
}
$text = array();
$text= array("headline" => $post->post_title, "text" =>$post->post_content);
$main_events[] = array("media" => $media, "start_date" => $startdate , "end_date" => $enddate , "text" => $text);
}
$output = array("title" => $main_title, "events" => $main_events);
wp_reset_query();
$outputjson = json_encode($output);
echo $outputjson;
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 7.1.7 0.011 0.007 17.04 7.1.6 0.018 0.015 34.89 7.1.5 0.028 0.016 34.73 7.1.4 0.031 0.006 34.50 7.1.3 0.025 0.016 34.56 7.1.2 0.028 0.008 34.52 7.1.1 0.007 0.014 16.08 7.1.0 0.011 0.006 16.46 7.0.20 0.011 0.008 16.50 7.0.19 0.015 0.006 16.20 7.0.18 0.000 0.018 15.99 7.0.17 0.013 0.006 15.85 7.0.16 0.009 0.010 15.99 7.0.15 0.009 0.012 16.04 7.0.14 0.006 0.016 16.09 7.0.13 0.009 0.012 16.31 7.0.12 0.010 0.006 16.43 7.0.11 0.003 0.016 16.18 7.0.10 0.007 0.011 16.13 7.0.9 0.010 0.013 16.33 7.0.8 0.015 0.009 16.39 7.0.7 0.017 0.007 16.09 7.0.6 0.010 0.012 16.11 7.0.5 0.006 0.016 16.32 7.0.4 0.007 0.010 16.41 7.0.3 0.013 0.006 16.39 7.0.2 0.015 0.007 16.25 7.0.1 0.007 0.014 16.44 7.0.0 0.012 0.006 16.24
preferences:dark mode live preview
142.92 ms | 1386 KiB | 7 Q