【发布时间】:2014-03-23 15:45:42
【问题描述】:
我真的需要一些帮助。从昨天早上开始,我一直在努力为我女朋友在 wordpress 中的烘焙和烹饪食谱博客构建一个定制设计,此时我感到非常沮丧。 我按照 Lynda.com 教程在 wordpress 中进行自定义设计,并设法将模板分为页眉、主要部分和页脚,但在那之后我有点卡住了。 这是一个原始的 html 页面,可以查看该站点的外观: http://natalija.co.nf/index.html
这里是我需要帮助的地方。我希望将主页分成几个部分,每个部分都有一个唯一的 ID 和 data-stellar-background-ratio="0.5" 用于视差背景效果。这些部分将代表类别(蛋糕、饼干、饮料、菜肴等)。每个类别都应包含一篇具有自己的类和 data-stellar-ratio="1.5" 的文章。在一篇文章中,将有一个带有类别标题的 h1 标记和一个 jquery 滑块,其中包含指向该类别的食谱的链接。 所以一个section的结构应该是这样的:
<section id="teroteikolaci" data-stellar-background-ratio="0.5">
<article class="torteikolaci" data-stellar-ratio="1.5">
<h1>TORTE I KOLAČI</h1>
<div class="wrapper">
<ul class="slider">
<li class="slide">
<a href="#">
<img src="wp-content/themes/Natalija/images/torte-i-kolaci-thumb01.jpg" alt="random">
<div class="bubble">
<h5>Čoko mousse torta 1</h5>
</div>
</a>
</li>
<li class="slide">
<a href="#">
<img src="wp-content/themes/Natalija/images/torte-i-kolaci-thumb02.jpg" alt="random">
<div class="bubble">
<h5>Čoko mousse torta 2</h5>
</div>
</a>
</li>
<li class="slide">
<a href="#">
<img src="wp-content/themes/Natalija/images/torte-i-kolaci-thumb03.jpg" alt="random">
<div class="bubble">
<h5>Čoko mousse torta 3</h5>
</div>
</a>
</li>
</ul>
</div>
</article>
</section>
正如我所说,我设法将模板分成 header.php、footer.php 和 home.php, 但是我只设法将原始 html 代码放入 home.php 中,我想用动态内容替换它,但是我在教程中的那个人后面迷路了。 我不希望类别成为单独的页面。我希望它们都显示在主页中。我该如何做到这一点? 我是 wordpress 的新手,所以仪表板有点让我困惑,而且我不熟悉 wordpress php 功能,所以如果有人能给我一些关于如何解决这个问题的指导,我将不胜感激。
编辑:
<?php
$args = array(
'orderby' => 'name',
'order' => 'ASC'
);
$categories = get_categories($args);
foreach($categories as $category) {
?>
<section id="<?php echo $category->slug; ?>" data-stellar-background-ratio="0.5">
<article class="<?php echo $category->slug; ?>" data-stellar-ratio="1.5">
<h1><?php echo $category->name; ?></h1>
<div class="wrapper">
<ul class="slider">
<?php
}
$args = array (
'post_status' => 'publish',
'category_name' => $category->slug,
'nopaging' => true,
);
$custom_query = new WP_Query( $args );
if ( $custom_query->have_posts() ) {
while ( $custom_query->have_posts() ) {
$custom_query->the_post();
// begin your slider loops in here
?>
<li class="slide">
<a href="<?php echo get_permalink(); ?>">
<?php the_post_thumbnail(); ?>
<div class="bubble">
<h5><?php echo get_the_title(); ?></h5>
</div>
</a>
</li>
<?php }
} else {
// no posts found
}
/* Restore original Post Data */
wp_reset_postdata();
?>
</ul>
</div>
</article>
</section>
【问题讨论】:
标签: wordpress-theming wordpress