Php wordpress的mashable-like-next-post小部件
我想包括一个类似Mashable的函数。这是下一个贴子。如果你到达文章的末尾,一个建议会出现在右边。我找到了一个解决办法,但对我不起作用 我是这样做的: 1,将nextpost.js文件添加到Web服务器的根目录中Php wordpress的mashable-like-next-post小部件,php,javascript,jquery,wordpress,Php,Javascript,Jquery,Wordpress,我想包括一个类似Mashable的函数。这是下一个贴子。如果你到达文章的末尾,一个建议会出现在右边。我找到了一个解决办法,但对我不起作用 我是这样做的: 1,将nextpost.js文件添加到Web服务器的根目录中 $(function(){ //When should it be triggered in this case - when the '.next-link' is visible, but it could be the '.offset().bottom' of the art
$(function(){
//When should it be triggered in this case - when the '.next-link' is visible, but it could be the '.offset().bottom' of the article?
limit = $('.next-link').offset().top;
//Account for the height of the window - would have to readjust on resize;
target = limit - $(window).height();
//Hide the fancy fixed position box;
$nextbox = $('.next-box')
$nextbox.css({right: '-=150px'});
//Make a note of it's status;
visible = false
//Cue Magic - every time the window scrolls;
$(window).scroll(function(){
//Where are we?
current = $(window).scrollTop();
//Hit the target - show me the box;
if(current >= target && visible == false){
$nextbox.animate({right: '+=150px'}, 500);
visible = true;
}
//Gone back up to re-read the article - hide it again!
if(current < target && visible == true){
$nextbox.animate({right: '-=150px'}, 500);
visible = false;
};
});
$(函数(){
//在这种情况下,当“.next link”可见,但它可能是文章的“.offset().bottom”时,应该何时触发?
限制=$('.next link').offset().top;
//考虑到窗户的高度-在调整尺寸时必须重新调整;
目标=限制-$(窗口).height();
//隐藏奇特的固定位置框;
$nextbox=$(“.next box”)
$nextbox.css({右:'-=150px'});
//记下它的状态;
可见=假
//提示魔术-每次窗口滚动;
$(窗口)。滚动(函数(){
//我们在哪里?
当前=$(窗口).scrollTop();
//击中目标-给我看盒子;
如果(当前>=target&&visible==false){
$nextbox.animate({right:'+=150px'},500);
可见=真实;
}
//返回重新阅读文章-再次隐藏它!
如果(当前
}))
2,在头部放置以下代码:
<script type="text/javascript" src=".../nextpost.js"></script>
3、添加代码:
<div class="next-link">fb-share button</div>
<div class="next-box">code of a wp widget area</div>
fb共享按钮
wp小部件区域的代码
问题是,小部件区域(下一个框)总是出现,而不仅仅是当我到达下一个链接部分时。我认为问题在于javascript集成。我该怎么办?我找到了一个wp插件。它解决了我的问题,请将您的评论移至回答框。