【问题标题】:jquery slider and wordpressjquery滑块和wordpress
【发布时间】:2012-02-14 17:14:05
【问题描述】:

我对 wordpress、html、css 和 javascript 还是很陌生,如果可能的话,我很想得到你的帮助:

我正在尝试为我的博客的特色内容区域创建一个双滑块,其中左侧滑块上有三个精选的 youtube 视频,右侧滑块上有帖子摘录。 Here's how I picture it.

我认为我目前这样做效率低下;使用dualslider

现在我在右侧面板上有三个 div,每个帖子对应一个在每个 div 中输出 the_excerpt() 的帖子:

<div class="detail" >
      <?php $args=array('tag' => 'Featured1', 'showposts'=>1, 'caller_get_posts'=>1);
               $my_query = new WP_Query($args);
                      if( $my_query->have_posts() ) 
                {
                      while ($my_query->have_posts()) : $my_query->the_post(); ?>
                      <p><a href="<?php the_permalink() ?>" <?php the_title(); ?></a></p>
                      <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>

                      <h3><?php the_excerpt(); ?></h3>
                        <?php endwhile;
                }
                      wp_reset_query(); ?>
</div><!--END detail1-->

左侧有三个 div,每个视频对应一个将 the_content 输出到每个 div 的视频:

<div class="detail" >
      <?php $args=array('tag' => 'Featured1', 'showposts'=>1, 'caller_get_posts'=>1);
               $my_query = new WP_Query($args);
                      if( $my_query->have_posts() ) 
                {
                      while ($my_query->have_posts()) : $my_query->the_post(); ?>
                      <p><a href="<?php the_permalink() ?>" <?php the_title(); ?></a></p>
                      <h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>

                      <h3><?php the_content(); ?></h3>
                        <?php endwhile;
                }
                      wp_reset_query(); ?>
</div><!--END detail1-->

我想要推荐的三个帖子分别标记为 Featured1、Featured2 和 Featured3,帖子内容只是 iframe youtube 嵌入代码,后跟我想要在正确内容面板中显示的任何内容。

最后,由于我不太了解双滑块 javascript 文件,除了很难格式化视频的轮播大小之外,我的另一个问题是,当您从幻灯片移动到时,我需要暂停当前正在播放的视频幻灯片类似于 AnythingSlider (http://css-tricks.com/examples/AnythingSlider/#panel1-4) 中提供的功能。

任何帮助将不胜感激。谢谢!

【问题讨论】:

  • caller_get_posts 已弃用。
  • 我觉得整个东西都是垃圾,但是我应该用什么代替呢?
  • 好吧,老实说,您的方法可能不是最好的。您应该只使用一个循环来提高性能。然后,如果你对这一切都不熟悉,我建议你从更简单的开始。这会变得太复杂了......
  • 我不会轻易气馁。如果你真的想帮我给我发一封电子邮件,我可以更好地向你解释我想要完成的工作。

标签: jquery wordpress slider anythingslider


【解决方案1】:

试试这个...

https://gist.github.com/1848388

我已将查询和循环 php 添加到 index.html 演示文件中。

这是我下载的演示包...Dual Slider Demo File

我没有测试它,所以它可能不起作用哈,我已经调整了您的查询以检索带有“精选”标签的最新 3 篇帖子。

另外,不要使用&lt;?php the_content(); ?&gt; 作为图片或视频,为什么不使用自定义字段,这样您仍然可以在帖子中拥有完整的文章内容。

如果您将&lt;?php the_content(); ?&gt; 用于滑块中的特色图片或视频,那么您的所有帖子内容都会进入该区域,如果您的帖子中有大量文字和其他图片,这可能会很麻烦。

所以我在gist 中包含了自定义字段,替换了&lt;?php the_content(); ?&gt;,您所要做的就是创建一个名为...的自定义字段...

滑块特色图片

...并将图像代码或视频嵌入代码粘贴到此。创建此自定义字段后,滑块特色图片将被保存,您将能够从帖子编辑器的其他功能的下拉列表中选择它。

我已经评论了gist,所以你知道发生了什么。

祝你好运

【讨论】:

  • 非常感谢您的帮助!我将测试它作为我的吉米装配的任何滑块的替代品。
  • 如果您遇到困难,或者想使用新的 jquery 滑块而不是 dualslider,请告诉我。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-23
  • 2016-10-22
  • 1970-01-01
相关资源
最近更新 更多