AJAX call for posts through separate page
-
Creating an ajax more-posts options
I’m using jQuery’s load function to call information from a separate page which receives variables through $_GET, creates an $args and calls $wp_get_recent_posts
It’s obviously inappropriate to call $wp_get_recent_posts without relating the external page in some way to wordpress and it’s database but I can’t find the best way to do so
I’m getting an Internal Server Error, so the $().load is returning nothing.
My morePosts.php:
<?php $offset = $_GET["offset"]; $to_get = $_GET["to_get"]; $args = array( 'numberposts' => $to_get, 'offset' => $offset, ); $new_posts = wp_get_recent_posts( $args ); for ($i = 0; $i < $to_get; $i++){ echo '<div class="post">'; echo '<h2>'.$new_posts[$i]["post_title"].'</h2><p>'.$new_posts[$i]["post_content"].'</p>'; echo '</div>'; } ?>
any help is really appreciated
- The topic ‘AJAX call for posts through separate page’ is closed to new replies.