<?php
require_once("../wp/wp-config.php");
$now_post_num = $_POST['now_post_num'];
$get_post_num = $_POST['get_post_num']+1;
$get_post_slug = $_POST['get_post_slug'];
$results = $wpdb->get_results($wpdb->prepare("
SELECT
$wpdb->posts.ID,
$wpdb->posts.post_author,
$wpdb->posts.post_title,
$wpdb->posts.post_content,
$wpdb->terms.name
FROM $wpdb->posts
JOIN wpdb−>termrelationshipsONwpdb->term_relationships.object_id = $wpdb->posts.ID
JOIN wpdb−>termtaxonomyONwpdb->term_taxonomy.term_taxonomy_id = $wpdb->term_relationships.term_taxonomy_id
JOIN wpdb−>termsONwpdb->terms.term_id = $wpdb->term_taxonomy.term_id
WHERE wpdb−>posts.posttype=′post′ANDwpdb->posts.post_status = 'publish' AND wpdb−>terms.slug=′get_post_slug'
ORDER BY
$wpdb->posts.post_date DESC
LIMIT nowpostnum,get_post_num
", OBJECT));
if ( count($results) < $get_post_num ) {
$noDataFlg = 1;
} else {
$noDataFlg = 0;
array_pop($results);
}
$html = "";
foreach ($results as $value) {
$html .= '<div class="card callout">';
$html .= '<div class="row">';
$html .= '<div class="large-3 medium-3 small-3 columns"><p>'.get_the_post_thumbnail($value->ID).'</p></div>';
$html .= '<h5><a href="'.get_permalink($value->ID).'">'.apply_filters('the_title', $value->post_title).'</a></h5>';
$html .= '<p class="excerpt">'.mb_substr(strip_tags($value-> post_content),0,100).'...</p>';
$html .= '<p class="posted text-right">'.$value->name.' '.get_the_date( 'Y.m.d', $value->ID ).' '.get_the_author_meta('display_name', $value->post_author ).' '.get_avatar($value->post_author,35).'</p>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
}
$returnObj = array();
$returnObj = array(
'noDataFlg' => $noDataFlg,
'html' => $html,
);
$returnObj = json_encode($returnObj);
echo $returnObj;
?>