Skip to content

Instantly share code, notes, and snippets.

@miznokruge
Created July 2, 2022 07:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miznokruge/679eb03c0d45c259d0286a9374e9085d to your computer and use it in GitHub Desktop.
Save miznokruge/679eb03c0d45c259d0286a9374e9085d to your computer and use it in GitHub Desktop.
<?php
require_once(dirname(__FILE__) . '/wp-config.php');
$wp->init();
$wp->parse_request();
$wp->query_posts();
$wp->register_globals();
$wp->send_headers();
// Your WordPress functions here...
///echo site_url();
$komen = [];
$comments = get_comments();
foreach ($comments as $c) {
if ($c->comment_author_email != '') {
$komen[] = [
'id' => $c->comment_ID,
'name' => $c->comment_author,
'email' => $c->comment_author_email,
'date' => $c->comment_date,
'content' => strip_tags($c->comment_content),
'post_title' => get_the_title($c->comment_post_ID),
'post_url' => get_permalink($c->comment_post_ID)
];
$kf = array($c);
}
}
$data['site_url'] = site_url();
$data['comments'] = $komen;
header("Content-Type:Application/json");
echo json_encode($data);
die;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment