Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 清漆ESI&;Wordpress-模拟加载帖子_Php_Wordpress_Varnish_Esi - Fatal编程技术网

Php 清漆ESI&;Wordpress-模拟加载帖子

Php 清漆ESI&;Wordpress-模拟加载帖子,php,wordpress,varnish,esi,Php,Wordpress,Varnish,Esi,更新:我自己已经回答了这个问题。见下文。 我想我要求的是一个等价的set\u id()函数,如果存在的话 我正在使用Wordpress和Varnish来提高性能,我想在侧边栏中使用ESI(Edge Side Include),这样最近/流行的文章可以比文章内容本身更频繁地刷新 正在插件目录等中创建端点,以便Varnish从ESI注释访问,代码如下: <?php /* ESI handler for Varnish - Sidebar (all tabs except search) */

更新:我自己已经回答了这个问题。见下文。

我想我要求的是一个等价的
set\u id()
函数,如果存在的话

我正在使用Wordpress和Varnish来提高性能,我想在侧边栏中使用ESI(Edge Side Include),这样最近/流行的文章可以比文章内容本身更频繁地刷新

正在插件目录等中创建端点,以便Varnish从ESI注释访问,代码如下:

<?php
/* ESI handler for Varnish - Sidebar (all tabs except search) */

$cwd = getcwd();
$path = substr($cwd, 0, strpos($cwd, 'wp-content/'));
require $path . 'wp-blog-header.php';


    echo '<!-- ESI sidebar created '.date(DATE_RFC2822).' -->',"\n";
    if ( ! dynamic_sidebar( 'primary-widget-area' ) )
    {
        echo '<!-- Unable to load primary-widget-area (sidebar) -->';
    }
?>
但它什么也没用

我还想知道
WP\u Post::get\u instance()
(它似乎只接受一个对象,而不是Post ID)

还有什么我可以用的吗

$query = new WP_Query( 'p=1' );

if ( $query->have_posts() ) {
    $query->the_post();   // this loads it
}
有关所有其他参数,请参见

$query = new WP_Query( 'p=1' );

if ( $query->have_posts() ) {
    $query->the_post();   // this loads it
}