我为客户创建了一个自定义 Wordpress 主题,并试图利用 Jetpack 的无限滚动功能,但无法使其正常工作。我对 Wordpress 比较陌生,但花了几个小时试图解决这个问题。
以下是该网站的链接:
http://wpportmanteau.cityonfilm.com/
我在我的 functions.php 文件中添加了对无限滚动的主题支持
<?php
add_theme_support( 'post-thumbnails' );
add_theme_support( 'infinite-scroll', array(
'type' => 'scroll',
'footer_widgets' => false,
'container' => 'content',
'wrapper' => true,
'render' => false,
'posts_per_page' => false,
) );
?>
根据本文,我正在使用 get_template_part 函数:
http://ottopress.com/2012/jetpack-and-the-infinite-scroll/
生成帖子的 content.php 文件如下:
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<div class="window preview">
<div class="poster preview" style="background: url(<?php echo $url; ?>); background-size:cover;">
<h2><?php the_time('m/d'); ?></h2>
</div>
<div class="info preview">
<div class="postInfo">
<a href="<?php the_permalink(); ?>"><h1><?php the_title(); ?></h1></a>
<p> <?php the_tags('',' / ',''); ?> </p>
<?php echo sharing_display(); ?>
</div>
<div class="toolbar">
<a target="_blank" class="large button" href="<?php echo get_post_meta($post->ID, 'Download', true); ?>" title="Download"><img src="<?php bloginfo('template_url'); ?>/images/dl.png"></a><a class="large button" href="<?php echo get_post_meta($post->ID, 'Stream', true); ?>" title="Stream"><img src="<?php bloginfo('template_url'); ?>/images/stream.png"></a>
</div>
</div>
</div>
我知道我的帖子的结构有点奇怪,但我在生成它们时没有任何问题。
提前感谢您的任何建议/支持。让我知道我是否可以提供更多信息来澄清。