Javascript 如何在下一篇文章之前将标题固定在wordpress博客上?

Javascript 如何在下一篇文章之前将标题固定在wordpress博客上?,javascript,php,wordpress,position,blogs,Javascript,Php,Wordpress,Position,Blogs,我想让每篇文章的标题和文本固定在左边,而文章的图片滚动。当你读到下一篇文章时,我希望标题回到第一篇文章的顶部,并以新文章开始一个新标题 例如,我在收藏夹部分找到了cargocollective网站: 这是我已经找到的一段代码,但我不知道如何将其包含在php循环中 下面是我的php代码 <div id="content""> <div class="post"> <div class="textpost"> <h1><a href="<

我想让每篇文章的标题和文本固定在左边,而文章的图片滚动。当你读到下一篇文章时,我希望标题回到第一篇文章的顶部,并以新文章开始一个新标题

例如,我在收藏夹部分找到了cargocollective网站:

这是我已经找到的一段代码,但我不知道如何将其包含在php循环中

下面是我的php代码

<div id="content"">
<div class="post">

<div class="textpost">
<h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>
<?php the_time('m.d.y') ?>  
<?php the_category(', ') ?> 
<?php ob_start();
the_content('Read the full post',true);    
$postOutput = preg_replace('/<img[^>]+./','', ob_get_contents());    
ob_end_clean();    
echo $postOutput;    
?>    
</div>

<div class="imagepost">
<?php
       $beforeEachImage = "<div>";
       $afterEachImage = "</div>";
       preg_match_all("/(<img [^>]*>)/",get_the_content(),$matches,PREG_PATTERN_ORDER);
       for( $i=0; isset($matches[1]) && $i < count($matches[1]); $i++ ) {
             echo $beforeEachImage . $matches[1][$i] . $afterEachImage;
       }
    ?>
</div>
</div>

<?php endwhile; ?>
<?php endif; ?>
</div>

请在问题中发布所有相关代码,以便其他人可以从您的问题中受益。您好,我试图通过分享我的代码来帮助您。我不知道你是否看了一下,但标题在正确的移动方式正是我想做的
var windw = this;

$.fn.followTo = function ( elem ) {
var $this = this,
    $window = $(windw),
    $bumper = $(elem),
    bumperPos = $bumper.offset().top,
    thisHeight = $this.outerHeight(),
    setPosition = function(){
        if ($window.scrollTop() > (bumperPos - thisHeight)) {
            $this.css({
                position: 'absolute',
                top: (bumperPos - thisHeight)
            });
        } else {
            $this.css({
                position: 'fixed',
                top: 0
            });
        }
    };
$window.resize(function()
{
    bumperPos = pos.offset().top;
    thisHeight = $this.outerHeight();
    setPosition();
});
$window.scroll(setPosition);
setPosition();
};

$('#textpost').followTo('#textpost');