2024 年 4 月 28 日 我的频道
旅游网站主题开发
  • 2021
  • Sunny

基于第二版的主题基础上,利用自定义字段开发,做到全面的兼容自适应,Css 代码重写,移动端充分利用 JQuery 进行菜单的控制。因为经历了第二版主题的开发,已经吸取了相当多的经验,在此基础上开发新的主题,可以说,水到渠成。目前第一阶段先设计好 Html 模板,做到全面兼容后,后续传入数据就不在话下。现在设计模板也有一点过的难点,需要灵感来带动开发的进程,目前在网上闲逛,看看别人的设计,希望会自己的设计带来灵感吧!

自定义字段插件的诞生,让我们不用再做代码狂,增加一些功能不必再在 Function.php 上大做文章,而我们只需懂得如何循环输出自定义的字段数据,配合 Css 布局,就可以实现想要的功能的主题,实在方便!

这次主题主要实现如下功能:

  1. 实现旅行路线的添加,包括天数、价钱等;
  2. 实现每天的路线说明,列出每天路线相关的图片;
  3. 实现前端各个旅程的图片列表,方便查找;
  4. 实现旅行路线网上预订;
  5. 针对旅行路线、旅行天数、旅行价格等参数,写一个高级搜索引擎;

其他功能会和客户沟通再进行开发,充分利用自定义字段的优势,开发出最轻量级,最容易上手,速度最快的主题。

开发历程:

  1. 主题文件分离,创建 index.php , header.php, footer.php, functions.php, single.php
  2. 开启菜单、小工具、特色图像功能;
  3. 建立菜单,设置在菜单位置显示;
  4. 主页设置显示所有分类列表,并显示每个分类的图像作为背景,需要插件:Categories Images,前端分类列表以及显示分类图片作为背景,代码:

    PHP

    <?php
    $args = array(
    ‘hide_empty’ => false,
    ‘orderby’ => ‘ID’,
    ‘order’ => ‘ASC’,
    ‘posts_per_page’ => 8,
    ‘parent’ => $term_id,
    );
    $categories = get_categories( $args );
    foreach ( $categories as $category ) {
    ?>
    <div style=”background:url(<?php echo z_taxonomy_image_url( $category->term_id); ?>)”>
    <label><?php echo $category->name;?></label>
    </div>
    <?}?>
  5. 实现在线预约功能;
  6. 实现自定义字段设置为按钮群属性控制文章状态,前端列表显示:

    PHP

    <div class=”route-list grid-4″>
    <?php
    $args = array(
    ‘numberposts’ => 8,
    ‘orderby’ => ‘DESC’,
    ‘post_status’ => ‘publish’,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘hot’,
    ‘value’ => ‘yes’,
    )
    )
    );$rand_posts = get_posts( $args );
    foreach ( $rand_posts as $post ): ?>
    <figure>
    <div class=”featured”>
    <?php the_post_thumbnail();?>
    <div class=”tours”>
    <?php the_field(‘days’);?>
    Tours</div>
    <div class=”price”>$
    <?php the_field(‘price’);?>
    </div>
    </div>
    <h1><a href=”<?php the_permalink(); ?>”>
    <?php the_title(); ?>
    </a></h1>
    <div class=”route-content”>
    <?php the_excerpt();?>
    </div>
    </figure>
    <?php endforeach; ?>
    </div>
  7. 全站实现模块化数据导入:

    PHP

    get_template_part(‘./template/about-box’);
    about-box 为 about-box.php
    导入时请把后缀去掉;
  8. 关于其他页面获取分类的方法,以及循环输出某分类下的文章,以及判断自定义字段属性的文章:

    PHP

    <?php
    $current_category_ID = get_query_var( ‘cat’ );
    $args = array(
    ‘showposts’ => 8,
    ‘cat’ => $current_category_ID,
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘recommend’,
    ‘value’ => ‘yes’,
    )
    )
    );
    $posts = get_posts( $args );
    foreach ( $posts as $post ):
    ?>
    <figure>
    <div class=”featured”>
    <?php the_post_thumbnail();?>
    <div class=”tours”>
    <?php the_field(‘days’);?>
    Tours</div>
    <div class=”price”>$
    <?php the_field(‘price’);?>
    </div>
    </div>
    <h1><a href=”<?php the_permalink(); ?>”>
    <?php the_title(); ?>
    </a></h1>
    <div class=”route-content”>
    <?php the_excerpt();?>
    </div>
    </figure>
    <?php endforeach; ?>

待续 ……

WORDPRESS
2589
1

Author Box

名字:Sunny
注册:Jan 30, 2021
简介:技术菜鸟,拷贝、黏贴代码中 ……

Comment Box

5 1 投票
Article Rating
订阅评论
提醒
guest

1 评论
最旧
最新 最多投票
内联反馈
查看所有评论