<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                課程:[https://ke.qq.com/course/448367](https://ke.qq.com/course/448367) 【theme基本顯示】 可以跳過自己搭建wordpress后臺核心函數的調用 直接在twentyseventeen選取functions.php和inc文件夾,實現官方模板使用的wordpress核心函數 添加wordpress主題根目錄函數 ``` <?php bloginfo('template_directory'); ?> // 對應的文件夾為: <?php bloginfo('template_directory'); ?>/css/ <?php bloginfo('template_directory'); ?>/js/ <?php bloginfo('template_directory'); ?>/images/ ``` 首頁路徑 ``` <?php echo get_option('home'); ?> ``` 網站標題 ``` <?php bloginfo('name'); ?> ``` 網站描述 ``` <?php bloginfo('description'); ?> ``` 【get_template_part();的使用】 ``` <?php get_template_part( 'nav' ); ?> // Navigation bar (nav.php) <?php get_template_part( 'nav', '2' ); ?> // Navigation bar #2 (nav-2.php) <?php get_template_part( 'nav', 'single' ); ?> // Navigation bar to use in single pages (nav-single.php) ``` 【#分拆為header.php和footer.php】 index.php提取的代碼: ``` <?php get_header(); ?> <?php get_footer(); ?> ``` 在wordpress主題中,通常會有`<?php wp_head(); ?>`和`<?php wp_footer(); ?>`這兩個是wordpress插件向主題頭部和尾部加載內容使用的函數。這樣方便在主題指定位置中動態添加代碼,來實現插件的動態配置。 ``` <?php wp_head(); ?> <?php wp_footer(); ?> ``` 參考: [https://www.menglei.net/2721/](https://www.menglei.net/2721/) 【#文章循環輸出】 ``` <?php $categores = new WP_Query('post_type=post&cat=&posts_per_page=12'); if($categores->have_posts()): while($categores->have_posts()) : $categores->the_post(); ?> <!-- code... --> <?php endwhile; else: endif; ?> ``` ``` <?php the_title(); ?> <?php the_time('Y年n月j日, G:i:s'); ?> <?php the_permalink(); ?> <?php the_post_thumbnail('product-thumbnails'); ?> <?php the_category(); ?> ``` funtion.php ``` add_image_size( 'product-thumbnails', 500, 202, true ); add_image_size( 'product-thumbnails-search', 500, 185, true ); ``` 【#文章內容】 ``` <?php if(have_posts()): while(have_posts()): the_post(); the_content(); endwhile; else: // something can say this is nothing endif; ?> <?php previous_post_link('上一頁: %link'); ?><br/> <?php next_post_link('下一頁: %link'); ?> ``` 【#菜單】 ``` <li> <?php $args = array( //指定顯示的導航名,如果沒有設置,則顯示第一個 'theme_location' => 'top', //導航菜單ul標簽的class名 'menu_class' => '', //導航菜單ul標簽的id名 'menu_id' => "nav" ); wp_nav_menu($args); ?> </li> ``` 【#分類】 集合: ``` <?php the_category(); ?> ``` 可加入分隔符: ``` <?php $categories = get_the_category(); $separator = ", "; $output = ''; if($categories) { foreach ($categories as $key => $category) { $output .= '<a href="' . get_category_link($category->term_id) . ' ">' . $category->cat_name . '</a>'. $separator; } echo trim($output, $separator); } ?> ``` 【#留言功能】 ``` <?php if(comments_open() || get_comments_number()): comments_template(); endif; ?> ``` 總分類 ``` <?php wp_list_cats('sort_column=name&optioncount=0&hierarchical=0'); ?> ``` 最新內容 ``` <?php wp_get_archives('type=postbypost&limit=10'); ?> ``` 【4.頁面、文章樣式選擇顯示】 設置頁面模板,需要在指定頁面加入如下代碼: ``` <?php /* template name:模板名字 */ ?> ``` 【指定循環輸出數量文章】 ``` <?php $current_page = max(1, get_query_var('paged')); //當前第幾頁 //查詢參數 $args = array_filter(array( // 'orderby' => 'title', // 'order' => 'ASC', 'post_type' => 'post', 'ignore_sticky_posts' => 1 , 'posts_per_page' => 18, 'paged' => $current_page, //當前頁 )); //開始查詢 $query = new WP_Query($args); $total_pages = $query->max_num_pages; //總共多少頁 while ($query->have_posts()): $query->the_post(); ?> <!-- post code --> <?php endwhile; ?> <li> <!-- 輸出分頁 --> <?php echo paginate_links( array( 'prev_text' => __( '上一頁', 'YChinaTours' ), 'next_text' => __( '下一頁', 'YChinaTours' ), 'screen_reader_text' => null, 'total' => $total_pages, //總頁數 'current' => $current_page, //當前頁數 ) ); ?> </li> ``` 【分類和其他類型的文章歸類】 ``` <?php if(have_posts()) : ?> <?php if( is_category()){ single_cat_title(); }elseif(is_tag()){ single_tag_title(); }elseif(is_author()){ the_post(); echo 'Author Archives:'. get_the_author(); rewind_posts(); }elseif(is_day()){ echo 'Daily Archives:' .get_the_date(); }elseif(is_month()){ echo 'Daily Archives:' .get_the_date('F Y'); }elseif(is_year()){ echo 'Daily Archives:' .get_the_date('Y'); }else{ echo 'Archives'; } ?> <?php while(have_posts()) : the_post(); ?> <!-- post code --> <?php endwhile; ?> <?php echo paginate_links(); ?> <?php else : ?> <center><h2>對不起,沒有找到相關內容,請搜索其他關鍵詞</h2></center> <?php endif; ?> ``` 【搜索頁面】 搜索: ``` <?php the_search_query(); ?> ``` ``` <?php if(have_posts()) : ?> <center> <h2>搜索結果:<?php the_search_query(); ?></h2> </center> <?php while(have_posts()) : the_post(); ?> <!-- post code --> <?php endwhile; ?> <?php echo paginate_links(); ?> <?php else : ?> <h2><strong>沒有找到</strong>你想要找的東西 :-(</h2> <h3>請重新搜索<strong>相關的</strong>關鍵詞 !</h3> <?php endif; ?> ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看