/** * return posts data via AJAX. */ function kamome_note_get_more_posts() { if (!is_admin()) { echo 'illegal request'; die; } if (!isset($_GET['query']) || !isset($_GET['stickies']) || !isset($_GET['nonce'])) { echo 'illegal request'; die; } if (!wp_verify_nonce($_GET['nonce'], KAMOME_NOTE_AJAX_LOAD_MORE_ACTION)) { echo 'illegal request'; die; } $args = $_GET['query']; //filter query $acceptable = kamome_note_ajax_acceptable_queries(); foreach ($args as $key => $value) { if (!in_array($key, $acceptable) && isset($args[$key])) { unset($args[$key]); } } $args['paged'] = (int) $args['paged'] + 1; $posts = get_posts($args); foreach ($posts as $post) { if (!in_array($post->ID, json_decode($_GET['stickies']))) { //stickies must already displayed, should be skipped. kamome_note_abbr_post($post); } } die; }
/* Start the Loop */ ?> <?php $stickies = array(); ?> <?php while (have_posts()) { the_post(); ?> <?php /* * Include the Post-Format-specific template for the content. * If you want to override this in a child theme, then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ kamome_note_abbr_post($post); if (is_sticky($post->ID)) { array_push($stickies, $post->ID); } ?> <?php } ?> <?php /* finish the Loop */ ?> </div><!--#articles_wrapper--> <?php kamome_note_load_more_navigation($stickies); ?>