我正在创建新闻滑块,它看起来像这样
< ___________ #slideContent _______________> <#slideMenu>
┌────────────────────────────────────────────┬────────────┐
│ │<1st title> │
│ ├────────────┤
│ (Thumbnail of hovered title (1st)) │ 2nd title │
│ ├────────────┤
│ (\___/) │ 3rd title │
│ (=’.'=) ├────────────┤
│ (")_(") │ 4th title │
│ ├────────────┤
│ │ 5th title │
└────────────────────────────────────────────┴────────────┘
< > means hovered
Bunny is that article's thumbnail of hovered title. :)
这是我的代码。
<div id="slideshow">
<div id="slideContent">
<?php ???GET THUMBNAIL OF HOVERED TITLE?? ?>
</div>
<div id="slideMenu">
<div id="slideM1" class="marBo20"><?php ??GET TITLE OF LAST POST??></div>
<div id="slideM2" class="marBo20"><?php ??GET TITLE OF 2ND LAST POST??></div>
<div id="slideM3" class="marBo20"><?php ??GET TITLE OF 3RD LAST POST??></div>
<div id="slideM4" class="marBo20"><?php ??GET TITLE OF 4TH LAST POST??></div>
<div id="slideM5"><?php ??GET TITLE OF 5TH LAST POST??></div>
</div>
</div>
我不知道在#slideM1, #slideM2, #slideM3, #slideM4, #slideM5
DIV中输入什么以及在slideContent
内放置什么。
感谢您的帮助。 :)
答案 0 :(得分:1)
您可能需要为DIV修改此项,但这是您在<ul>
列表中的解决方案(来自WordPress Codex):
<ul>
<?php
global $post;
$args = array(
'numberposts' => 5,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish'
);
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
这是我刚刚制作的示例中的DIV版本。唯一缺少的是帖子缩略图:
<div id="slideshow">
<div id="slideContent">
</div>
<div id="slideMenu">
<?php
global $post;
$args = array(
'numberposts' => 5,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish'
);
$myposts = get_posts( $args );
$count = 0;
foreach( $myposts as $post )
{
$count++;
setup_postdata($post);
?>
<div id="slideM<?php echo $count; ?>" class="marBo20"><a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a></div>
<?php } ?>
</div>
</div>