下面是一个文件,它位于我为Wordpress提供的主题中,此页面由发布变量page
的jQuery Ajax帖子提取。
echo offset retuns the value 3.
但是
echo "hi";
根本没有回来,我做错了什么?
/inc/feed.php
<?php
include('./wp-load.php');
$display_count = 3;
$page = $_POST['page'];
$offset = ( $page - 1 ) * $display_count;
echo $offset;
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('post_type=project'.'&paged='.$page.'&offset='.$offset);
while ($wp_query->have_posts()) : $wp_query->the_post();
echo "hi";
?>
<section class="block project <?php echo( basename(get_permalink()) );?> project--white">
<div class="wrapper">
<div class="project__item">
<div class="project__item--block desk--two-fifths">
<h2><?php the_title(); ?></h2>
<p><?php echo content(35);?></p>
<p><a href="<?php the_permalink(); ?>" class="btn">View Case Study</a></p>
<p><?php the_tags( __( ' ' ), '<br/>');?></p>
</div>
<div class="project__item--block desk--three-fifths">
<?php if ( ( function_exists('has_post_thumbnail') ) && ( has_post_thumbnail() ) ) : ?>
<?php the_post_thumbnail( 'full' ); ?>
<?php endif; ?>
</div>
</div>
</div>
</section>
<?php endwhile; ?>
答案 0 :(得分:0)
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/wp-load.php";
include_once($path);
我必须将wp-load.php
包含更改为以下内容。
答案 1 :(得分:0)
Try this
/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/');
if ( defined('ABSPATH') )
require_once(ABSPATH . 'wp-load.php');
else
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );