Let me implement a custom publish retrieval page in wordpress. Essentially, I am using AJAX to refer to this as page that'll be passed a publish ID and retrieve certain data from that publish.

Note: do not mistake this like a template question. I don't want a template for just one single page -- I'm searching to create this site query multiple different posts according to postID and return certain data from that publish.

And So I attempted developing a page

<?php
$args=array(
       'p'=>'77'
    );
    $friends = new WP_Query($args);
?>
<?php if ($friends->have_posts()) : the_post(); ?>

    <?php the_title(); ?>
    <?php the_content(); ?>

<?php else: ?>
    <p>Sorry, no posts are available.</p>
<?php endif; ?>

But this doesn't work as it is not loading within the wordpress functions to handle query.

Thanks ahead of time for just about any help!

You need to range from the wordpress-blog-header.php file. When the page you're creating is within your theme's folder you would then put something similar to this towards the top of your code

<?php require_once ('../../../wp-blog-header.php');?>

I believe I you know what you are attempting to complete, also it seems like you're going about this the wrong manner. Don't create a 'new page' within the admin interface. What for you to do is offer personal files (JSON, XHTML fragment, whatever) for your Javascript and can include inside it Wordpress data, right? I understand this problem, getting tried on the extender in certain of my plug ins.

You will find two techniques:

(1) This really is what you ought to do: create a new wordpress plugin (only a loose php file in wordpress-plug ins with similar format header because the other plug ins inside). Write your function along wrinkles:

function mydatapage(){
    if (...$_SERVER['REQUEST_URI'] == the one I am using ...) {
        $args=array(
            'p'=>'77'
        );
        $friends = new WP_Query($args);
        if ($friends->have_posts()) :
            the_post();
            the_title();
            the_content();
        else:>?
<p>Sorry, no posts are available.</p>
        <?php endif;
        die();
    } //else do nothing and leave WP to serve the page normally
}
//Crucially:
add_action('init', 'mydatapage');

What that does is perform a research when pages are loaded to ascertain if the url matches the main one you need to hijack and employ to transmit your custom data. If it's, you signal the informationOrdocumentOrwhat ever you seem like and exit (die).

Provide a shout if you would like more in depth syntax. It's a little untidy, but is effective.

(2) Directly call your wordpress plugin file. Wordpress is only going to handle files that don't already exist, and then leave the relaxation to Apache. Which means you may make a wordpress plugin file and call that directly while using .../wordpress-wordpress plugin/myfile.php url. You should include a few of the Wordpress core files to obtain such things as Wordpress_Query to operate. It's marginally more fragile a technique.