【问题标题】:How can I create Content Slider in Wordpress如何在 Wordpress 中创建内容滑块
【发布时间】:2012-04-04 02:09:50
【问题描述】:

我需要在 wordpress 中创建一个图库以显示最新的 3 篇文章。画廊将显示帖子的图像以及帖子的标题和帖子的一部分(wordpress 中 --more-- 标签之前的段落)。当我添加画廊显示的新帖子时,我需要它是动态的。

我做了以下代码

<div class="blogsgallery">

        <?php query_posts('showposts=3'); ?>

        <?php while (have_posts()) : the_post(); ?>
        <p>
        <h3>
            <a href="<?php the_permalink() ?>" 
rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
                <?php the_title(); ?></a>
        </h3>
        </p>

        <div class="entry-content">

            <div id="post-thumbnail">
              //the size of thumbnail 150X150 px  
              <?php the_post_thumbnail(array(150,150)); ?> 
            </div>

//The code will show only the text before the "Read More ..." tag !
                <?php 
                global $more;
                $more = 0;
                the_content("Read More ...");
                ?>
        </div>

        <?php endwhile; ?>

    </div>

这是一个循环显示最新的 3 个帖子。我需要使它成为一个滑块容器。在特定时间后,即 1 分钟,幻灯片 1 向左移动并显示幻灯片 2,等等...

更多信息请看照片:

【问题讨论】:

    标签: wordpress wordpress-theming


    【解决方案1】:

    最简单的解决方案是通过您的设置更改显示的帖子数量。我想这对您来说不是一个好的解决方案;这是另一种方法:

    您需要在您的主题中编辑一个页面。您可以编辑主页;我会推荐您make a new page template 并将其用作您的首页。

    然后创建the loopquery_posts 的变体。使用 3 个帖子(每页)创建循环将按如下方式完成:

    query_posts( 'posts_per_page=3' );
    

    the Wordpress codex查看更多信息;特别是template tags 页面。

    【讨论】:

    • 如果是纯html;将其创建为静态文件;在此之后,你必须看看你的循环是如何适应的。
    • Brtrnd 我怎样才能把它做成幻灯片?我应该添加什么来制作带有左右滑动两个箭头的幻灯片......
    【解决方案2】:

    Btrnd 在技术上是正确的。但是,您似乎并不了解 Wordpress 模板的工作原理。 (我并不是要冒犯)。也许您正在寻找一个插件来为您做这件事?

    http://speckyboy.com/2010/06/30/top-10-content-slider-plugins-for-wordpress/

    您可以尝试上述帖子中的任何内容。要安装插件,请下载它并将其放在您的插件目录中。或者,您可以直接从 Wordpress 搜索插件并从 Wordpress 后端安装它们。有关如何执行此操作,请参阅法典(下面的链接)。

    http://codex.wordpress.org/Managing_Plugins#Installing_Plugins

    【讨论】:

    • 完全没问题。我需要从头开始制作并且需要动态,就在我插入新帖子时,它会立即显示该帖子。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-10-09
    相关资源
    最近更新 更多