2

我正在创建新闻滑块,它看起来像这样

< ___________ #slideContent _______________>  <#slideMenu>
┌────────────────────────────────────────────┬────────────┐
│                                            │&lt;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, #slideM5DIV 中输入什么以及在slideContent.

感谢您的任何帮助。:)

4

1 回答 1

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>
于 2013-05-18T15:01:24.110 回答