Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.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
Javascript Jetpack无限卷轴不工作_Javascript_Php_Jquery_Wordpress_Jetpack - Fatal编程技术网

Javascript Jetpack无限卷轴不工作

Javascript Jetpack无限卷轴不工作,javascript,php,jquery,wordpress,jetpack,Javascript,Php,Jquery,Wordpress,Jetpack,我一直试图让无限卷轴工作,但似乎无法让它工作 我有三个文件:post循环content-post-ft.php,functions.php,然后是我的首页,在那里,帖子正在加载frontpage.php Functions.php add_theme_support( 'infinite-scroll', array( 'container' => 'main-content', 'type' => 'scroll', 'footer' => 'foot',

我一直试图让无限卷轴工作,但似乎无法让它工作

我有三个文件:post循环
content-post-ft.php
functions.php
,然后是我的首页,在那里,帖子正在加载
frontpage.php

Functions.php

  add_theme_support( 'infinite-scroll', array(
  'container' => 'main-content',
  'type' => 'scroll',
  'footer' => 'foot',
  'render' => 'infinite_scroll_render'
   ));

 function infinite_scroll_render() {
   get_template_part( 'content-post-ft', 'standard' );
  }
<div class="hub-cont">
<?php

 $thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
 ?>
<div id="newsitem">
<div id="newsimg" style="background-image: url('<?php echo $thumb_url ?>')">
<a href="<?php the_permalink(); ?>"></a>
</div>
 <div id="newsname"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>          </div>
 <div id="newstext"><?php $text = $post->post_content; $trimmed = wp_trim_words( $text, 40, null );   echo $trimmed; ?></div>
 <div class="clear"></div>
 </div>

 <?php
// endwhile;
// endif;

wp_reset_postdata();?>

</div>
<div id="main-content">
 <?php

 $myargs = array (
 //'showposts' => 2,
'post_type' => 'post',
'category_name' => 'News'
);
$myquery = new WP_Query($myargs);
if($myquery->have_posts() ) :
while($myquery->have_posts() ) : $myquery->the_post();
    get_template_part( 'content-post-ft', get_post_format() );
endwhile;
 endif;
?>
 </div>
content-post-ft.php

  add_theme_support( 'infinite-scroll', array(
  'container' => 'main-content',
  'type' => 'scroll',
  'footer' => 'foot',
  'render' => 'infinite_scroll_render'
   ));

 function infinite_scroll_render() {
   get_template_part( 'content-post-ft', 'standard' );
  }
<div class="hub-cont">
<?php

 $thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
$thumb_url = $thumb_url_array[0];
 ?>
<div id="newsitem">
<div id="newsimg" style="background-image: url('<?php echo $thumb_url ?>')">
<a href="<?php the_permalink(); ?>"></a>
</div>
 <div id="newsname"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>          </div>
 <div id="newstext"><?php $text = $post->post_content; $trimmed = wp_trim_words( $text, 40, null );   echo $trimmed; ?></div>
 <div class="clear"></div>
 </div>

 <?php
// endwhile;
// endif;

wp_reset_postdata();?>

</div>
<div id="main-content">
 <?php

 $myargs = array (
 //'showposts' => 2,
'post_type' => 'post',
'category_name' => 'News'
);
$myquery = new WP_Query($myargs);
if($myquery->have_posts() ) :
while($myquery->have_posts() ) : $myquery->the_post();
    get_template_part( 'content-post-ft', get_post_format() );
endwhile;
 endif;
?>
 </div>


解决了。我不得不让Jetpack允许在自定义字段和页面上使用无限卷轴。默认情况下,它仅适用于原始帖子页面

函数文件:

function tweakjp_custom_is_support() {
return true;
$supported = current_theme_supports( 'infinite-scroll' ) && ( is_home() ||      is_archive() || is_front_page() );

return $supported;
}
  add_filter( 'infinite_scroll_archive_supported',      'tweakjp_custom_is_support' );

 function mm_infinite_scroll_render() {
    while ( have_posts() ) : the_post();
        get_template_part( 'content' );
    endwhile;
 }

  function mm_infinite_scroll_query_args($args) {

$new_args = array(
    'posts_per_page'   => $args['posts_per_page'],
    'paged'   => $args['paged'],
    'orderby'          => 'date',
    'order'            => 'DESC',
    'post_type'        => 'post',
    'post_status'      => 'publish',
);

return $new_args;
}

function mm_infinite_scroll_posts_where($clause) {
return "";
}

add_filter( 'infinite_scroll_posts_where', 'mm_infinite_scroll_posts_where' );

add_filter( 'infinite_scroll_query_args', 'mm_infinite_scroll_query_args',  9999 );
add_theme_support( 'infinite-scroll', array(
'container' => 'main-content',
'render' => 'mm_infinite_scroll_render'
) );
然后content.php文件具有呈现代码。我的看起来像这样是为了帮助那些不确定的人

<div class="news-list">
<ul class="promo-list-items">
    <?php
    // Fetch all posts relating to a certain tag then display 4 of them
    //Get the Thumbnail URL
    $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 720,405 ), false, '' );
    ?>
    <div id="promolink"></div><li class="news-list-item" style="background-image: url(' <?php echo $src[0];?> '); background-repeat: no-repeat; background-size: cover;"> <a class="gdbnewslink" href="<?php echo get_permalink();?>" >
            <?php the_title();?>
        </a>
        <?php wp_reset_postdata(); ?>
    </li>
    <div class="clear"></div>
</ul>
</div>


    你有没有试着在房间里找过?有错误吗?我看不出有错误。无论出于什么原因,页面都不想使用无限卷轴。我还在页面上进行了检查,以确保它正在运行,并且正在运行。只是有什么东西阻止了它的工作,我不知道是什么。