2015-02-27 2 views
-1

Я только что закончил создание бесконечного цикла для моего WordPress блоге, он работает прекрасно на моем локальном компьютере (WAMP), но когда я положил его в Интернете (Nginx сервер) его показ POST http://www.siteurl.com/infinite-loop.php 500 Internal Server ErrorAJAX POST 500 INTERNAL SERVER ERROR

Infinite_loop .php

<?php 

$infinite_loop= $_POST['pcount']; ?> 

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

    <div class="x-container-fluid max width main"> 
    <div class="offset cf"> 
     <div class="<?php x_main_content_class(); ?>" role="main"> 
      <?php 
        global $wpdb; 
        $args = array('posts_per_page' => 10, 'order' => 'DESC', 'offset'=>$infinite_loop);  
        $myposts = get_posts($args); 
        foreach ($myposts as $post) : setup_postdata($post); ?> 
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 


         <div> 
          <div style="width:300px; float:left;"> 
           <?php x_ethos_featured_index(); ?> 
          </div> 
          <div style="width:500px; float:right;"> 
           <?php /* print $args['offset']; */ ?> 
           <?php x_get_view('ethos', '_content', 'post-header'); ?> 
           <?php x_get_view('global', '_content'); ?> 
           <?php 


          </div> 
         </div> 
        </article> 
        <?php endforeach; 
           wp_reset_postdata(); ?> 


</div>  <?php get_sidebar(); ?> 
</div></div> 

АЯКС В ТЕМАТИЧЕСКОЙ HEADER

<script> 
$(document).ready(function() { 

var post_page_count = 10; 
var height_scroll = 400; 
    $(window).scroll(function() { 

    if ($('body').height() <= ($(window).height() + $(window).scrollTop())){ 
     post_page_count = post_page_count+10; 

     $.ajax({ 
      type: "POST", 
      async: false, 
      url: "theme/infinite_loop.php", 
      data: {pcount:post_page_count}, 
      success: 
       function(result){ 


        $("#gizinfi").append(result); 
        } 
     }); 
     }; 
}); 
}); 
</script> 

Я не знаю, в чем проблема. Он отлично работает на локальном ПК с WAMP, но на онлайн-сервере отображается его ошибка. Может кто-нибудь пожалуйста, пожалуйста, помогите мне узнать, в чем проблема? Пожалуйста, помогите ...

+0

Проверьте, что ошибка вы получаете, установив error_reporting (E_ALL); ini_set ("display_errors", 1); –

ответ

0

Я получил решение ... это WordPress вопрос заголовка Wordpress установлен, чтобы позволить развитие плагин стиль внешне. Введенный заголовок неверен, поэтому я получаю ошибку 404 и 500.

меняю что

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

Для

require('/wp-config.php'); 
$wp->init(); 
$wp->parse_request(); 
$wp->query_posts(); 
$wp->register_globals(); 
0

Для лучших практик WordPress вы должны использовать ajax functions WordPress. Поместите это в вашем файле functions.php темы

<?php 

    add_action('wp_ajax_my_inifinte_loop', 'my_inifinte_loop'); 
    add_action('wp_ajax_my_inifinte_loop', 'my_inifinte_loop'); 

    function my_inifinte_loop() { 

     $infinite_loop= $_POST['pcount']; 

     ?> 

      <div class="x-container-fluid max width main"> 
      <div class="offset cf"> 
       <div class="<?php x_main_content_class(); ?>" role="main"> 
        <?php 
          global $wpdb; 
          $args = array('posts_per_page' => 10, 'order' => 'DESC', 'offset'=>$infinite_loop);  
          $myposts = get_posts($args); 
          foreach ($myposts as $post) : setup_postdata($post); ?> 
          <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 


           <div> 
            <div style="width:300px; float:left;"> 
             <?php x_ethos_featured_index(); ?> 
            </div> 
            <div style="width:500px; float:right;"> 
             <?php /* print $args['offset']; */ ?> 
             <?php x_get_view('ethos', '_content', 'post-header'); ?> 
             <?php x_get_view('global', '_content'); ?> 
             <?php 


            </div> 
           </div> 
          </article> 
          <?php endforeach; 
             wp_reset_postdata(); ?> 


       </div>  <?php get_sidebar(); ?> 
      </div> 
     </div> 

     <?php 


     die(); 

    } 

?> 

Than обновить JavaScript, чтобы

<script> 
$(document).ready(function() { 

var post_page_count = 10; 
var height_scroll = 400; 
    $(window).scroll(function() { 

     if ($('body').height() <= ($(window).height() + $(window).scrollTop())){ 
      post_page_count = post_page_count+10; 

      $.ajax({ 
       type: "POST", 
       async: false, 
       url: "<?php echo admin_url('admin-ajax.php'); ?>", 
       data: { 
        pcount:post_page_count, 
        action: 'my_inifinte_loop' 
       }, 
       success: 
        function(result){ 
         $("#gizinfi").append(result); 
        } 
      }); 
     }; 
    }); 
}); 
</script> 
+0

Ошибка внутреннего внутреннего сервера пропала, но этот цикл не показывает никаких сообщений или заголовков или изображений ... –

+0

Я обновил код. Вы можете выполнить console.log в результате? –