Я использую следующий код для отображения последних сообщений в Wordpress с отметкой даты и времени в бегущей строке.
<script type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/
jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
var i = 0;
$(".marquee").last().addClass("last");
$(".marquee").each(function() {
var $this = $(this);
$this.css("top", i);
i += $this.height();
doScroll($this);
});
});
function doScroll($ele) {
var top = parseInt($ele.css("top"));
if(top < 0) { //bit arbitrary!
var $lastEle = $(".last");
$lastEle.removeClass("last");
$ele.addClass("last");
var top = (parseInt($lastEle.css("top")) + $lastEle.height());
$ele.css("top", top);
}
$ele.animate({ top: (parseInt(top)-600) },
200,'linear', function() {doScroll($(this))});
}
</script>
<div id="mholder">
<div class="marquee" style="height: auto">
<a title="<?php echo the_title() ?>" href="<?php the_permalink() ?>">
<?php echo $title_short ?></a><span><small><br/>
<?php the_time('F jS, g:i a') ?></small></span>
</div>
</div>
<style>
.marquee {
height: 50px
color: #ccc;
border: none;
position:absolute;
}
#mholder {
height: 600px;
width: 150px;
border: none;
position: absolute;
overflow: hidden;
}
</style>
I would like to make it so only 4 out of the 14 posts are displayed at a time. The scrolling mechanism is irregular and I'd like to make it smooth and steady. Furthermore, if anyone knows how to display specific category posts, that would be helpful.