English 中文(简体)
我想在单独存放的存放地点档案上打羊。
原标题:I want to run wp_query on a separate php file for an ajax call

例如:

<?php $numposts = $_POST[ showposts ]; ?>


<?php $home_query_bottom = new WP_Query("cat=&showposts=$num_posts&offset=5"); $b = 0; ?>
<ul class="thumbs">
    <?php while ($home_query_bottom->have_posts()) : $home_query_bottom->the_post();
        $do_not_duplicate = $post->ID; $b++; ?>

        <li class="post-<?php the_ID(); ?> thumb"><?php get_the_image( array(  custom_key  => array(  thumbnail  ),  default_size  =>  thumbnail ,  width  =>  160 ,  height  =>  160  ) ); ?></li>
    <?php endwhile; wp_reset_query(); $b = 0; ?>
</ul>

上面的法典载于其自己的网址上,可以由主要字典页面打电话,但我却发现一幅错误,说没有发现高档。 我之所以这样说是因为我没有使用也许有一席之地的头盔。 我需要那页什么来利用轮椅阶级?

最佳回答

You have to make the page that ajax calls a template page. Make a new page in your blog and assign the template. no headers no includes.

问题回答

You can turn the template engine off and then include the header.
// Include WordPress
define( WP_USE_THEMES , false);
require_once( PATHHERE/wp-blog-header.php );

您必须列入《语言》功能位于“语言”设施主名录上的文件:

define( WP_USE_THEMES , false);  
require_once( ../../../wp-load.php );

页: 1

我发现了一个有关这个主题的理论:here

这为我工作,也许会帮助其他人。

My situation is I have a js file that uses getScript. In that script i have a bunch of .load() calls to a php file. At the top I place this.

if (file_exists("../../../wp-load.php"))
    {
    require_once("../../../wp-load.php");
    }

更改<代码>。

Edit - 采用WP 3.4.1





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签