Dom manipulation and wordpress


Staff member
I've setup a wordpress site which loads an initial page and then uses jquery .load to grab other php pages. The pages are initially created in wordpress with a php include to a corresponding text .php file.

So the site loads its header once and then just creates and removes DOM elements using .load. I'm now at the point where I'm setting up the site's blog to display the wordpress posts. I've created a little loop which goes through the posts. When I open the loop through it works but when I load it by pointing to it's .php file I get a php error "Call to undefined function get_posts()".

    <div id="postsContainer">
    global $post;
    $args = array( 'numberposts' => 100 );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
        <div class="postBody">
        <h1 class="postTitle"><?php the_title(); ?></h1>
            <?php the_content(); ?>
            <div class="postAttachment">
            //display image attachments
            $args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post->ID ); 
            $attachments = get_posts($args);
            if ($attachments) {
                foreach ( $attachments as $attachment ) {
                    //echo apply_filters('testies', $attachment->post_title );
                    //echo "help me";

            <p class="postInfo">Posted by <?php $author = get_the_author(); echo $author . ', '; the_date(); ?></p>
            <div class="socialButtons">
            <a class="" href="mailto:type email address here?subject=I want to share this post with you from <?php bloginfo('name'); ?>&body=<?php the_title('','',true); ?>: 
<?php the_permalink(); ?>" title="Email to a friend" target="_blank">email this  |</a>
            <a href="<?php the_permalink() ?>">  share on facebook  |</a>
            <a href="<?php the_permalink() ?>">  share on google+  |</a>
            <a href="<?php the_permalink() ?>">  tweet</a>

    <?php endforeach; ?>