Below is a file that is inside a theme I have for Wordpress, this page is pulled in by a jQuery Ajax post that posts the variable page
.
echo offset retuns the value 3.
but
echo "hi";
doesn't return at all, what have I done wrong?
/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; ?>
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/wp-load.php";
include_once($path);
I had to change the wp-load.php
inclusion to the following.
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' );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.