head頭部
head開始需要放置
<meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1"> <meta name="Author" content="Supported by Eastern Studio | www.eastdesign.net" />
特別聲明的是,在360內(nèi)核下,可能由于部分網(wǎng)頁的樣式?jīng)]有寫好或者是其他兼容性問題,需要對不同內(nèi)核進(jìn)行規(guī)避操作:
若頁面需默認(rèn)用ie兼容內(nèi)核,增加標(biāo)簽:
<meta?name=”renderer”?content=”ie-comp”>
若頁面需默認(rèn)用ie標(biāo)準(zhǔn)內(nèi)核,增加標(biāo)簽:
<meta?name=”renderer”?content=”ie-stand”>
若頁面需默認(rèn)用極速核,增加標(biāo)簽
<meta?name=”renderer”?content=”webkit”>
head結(jié)尾部分有兩個(gè)注意
第一點(diǎn)是引入CSS樣式
<link href="<?php echo get_template_directory_uri(); ?>/css/font-awesome.min.css" rel="stylesheet"> <link href="<?php echo get_template_directory_uri(); ?>/css/bootstrap.min.css" rel="stylesheet" > <?php echo get_template_directory_uri(); ?>是為了獲取遠(yuǎn)程服務(wù)器中相應(yīng)目錄文件夾中的內(nèi)容
第二點(diǎn)是設(shè)置favicon
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" sizes="16x16 24x24 32x32 48x48"> <link rel="apple-touch-icon-precomposed" type="image/png" href="/apple-icon.png" sizes="114x114"> <meta name="apple-mobile-web-app-title" content="網(wǎng)站名稱">
主體部分
h1標(biāo)簽
當(dāng)前頁面H1標(biāo)簽有且只能有一個(gè);
在首頁,h1標(biāo)簽一般放置在logo上
<h1>
<a href=”<?php echo esc_url( home_url( ‘/’ ) ); ?>” title=”<?php echo esc_attr( get_bloginfo( ‘name’, ‘display’ ) ); ?>” >
<img width=”寬度大小” height=”高度大小” alt=”<?php bloginfo( ‘name’ ); ?>” src=”<?php echo esc_url( get_template_directory_uri() ); ?>/images/logo.png” >
</a>
</h1>
在內(nèi)頁,h1標(biāo)簽一般放置在當(dāng)前頁面的標(biāo)題上,這時(shí)候需要將logo上的H1拿掉,即設(shè)置兩種頭部,首頁的page-head-home.php ,內(nèi)頁是page-head.php
例如在about us頁面, <h1><?php the_title(); ?></h1>,這邊的<?php the_title(); ?>會直接讀取到頁面“about us”的名字;
a標(biāo)簽
首先當(dāng)a是出站鏈接的時(shí)候,需要rel=”nofollow”屬性
例如社會化分享圖標(biāo),<a href=”https://www.youtube.com/channel/ “? rel=”follow” title=””follow””>;
當(dāng)a站內(nèi)鏈接的時(shí)候則不需要,
例如獲取產(chǎn)品的鏈接,<a href=”<?php echo get_permalink($post->ID) ?>” title=”<?php echo $post->post_title ?>”>;
img標(biāo)簽
img是需要設(shè)置width和height屬性的;
針對本地圖片,直接<img width=”寬度大小” height=”高度大小” alt=”<?php bloginfo( ‘name’ ); ?>” src=”<?php echo esc_url( get_template_directory_uri() ); ?>/images/圖片名稱.png” >
針對wordpress后臺媒體庫需要動態(tài)調(diào)取的圖片,我們需要先通過FTP上傳timthumb.php到相應(yīng)目錄下(timthumb能夠?qū)崿F(xiàn)WordPress縮略圖截取)
<img width=”圖片寬度” height=”圖片高度” src=”<?php bloginfo(‘template_url’)?>/timthumb.php?src=圖片地址&h=圖片高度&w=圖片寬度&zc=1″ alt=”圖片名稱”/>
其中,h為縮略圖的高度,w為縮略圖寬度,zc有兩個(gè)屬性值,1表示裁剪,0表示按設(shè)置的高寬壓縮,不裁剪。
獲取wordpress可編輯部分內(nèi)容
<?php while ( have_posts() ) : the_post(); ?> <?php the_content(); ?> <?php endwhile; ?>
面包屑
<div class="breadcrumb"> <?php if(function_exists('bcn_display')) { bcn_display(); }?> </div><!-- .breadcrumb -->
Content部分小功能
針對產(chǎn)品頁面列出post
<ul class="news_center-list"> <?php $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; $search_args = array( ? 'post_type' => 'post', ? 'showposts' => 1000, ? 'paged' ? ? ? =>? $page ); query_posts($search_args); ? ?> ? <?php while ( have_posts() ) : the_post();?> <li> <a class="new_title" href="<?php echo get_permalink($post->ID) ?>" title="<?php echo $post->post_title ?>"><h5><?php the_title(); ?></h5></a> <p class="new_time">[<?php the_time('Y-m-j');?>]</p>? <div class="clearfix"></div> </li> <?php endwhile;?> <?php wp_reset_query();? ?> </ul>
針對分類頁面列出默認(rèn)post分類以及其下的posts
<aside id="categories-2" class="widget widget_categories"> ? ? ? <div class="aside-bg"> ? ? ? ? ? ? <h3 class="widget-title">Category</h3> ? ? ? ? ? ? <ul> ? ? ? ? ? ? <?php ?? ? ? ? ? ? $args=array( ?? ? ? ? ? ? ? ? 'orderby' => 'name', ?? ? ? ? ? ? ? ? 'order' => 'ASC', ?? ? ? ? ? ? ? ? 'number' => '50', ?? ? ? ? ? ? ? ? 'hide_empty' => '0', ?? ? ? ? ? ? ? ? 'parent' => 0 ?? ? ? ? ? ? ? ? ); ?? ? ? ? ? ? ? ? $categories=get_categories($args); ?? ? ? ? ? ? ? ? foreach($categories as $category) : ?? ? ? ? ? ? ? ? ?> ?? ? ? ? ? ? ? ? ? ? <li> ?? ? ? ? ? ? ? ? ? ? ? ? <div class="widget-categories-title"> ? ? ? ? ? ? ? ? ? ? ? ? ? <a href="<?php echo get_category_link( $category->term_id ) ?>" title="<?php echo $category->name ?>"> ?? ? ? ? ? ? ? ? ? ? ? ? ? <?php echo $category->name ?> ? ? ? ? ? ? ? ? ? ? ? ? ? </a> ?? ? ? ? ? ? ? ? ? ? ? ? </div> ?? ? ? ? ? ? ? ? ? ? ? ? <ul class="widget-categories-children"> ? ? ? ? ? ? ? ? ? ? ? ? ? <?php ?? ? ? ? ? ? ? ? ? ? ? ? ? ? $page = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1; ?? ? ? ? ? ? ? ? ? ? ? ? ? ? $search_args = array( ?? ? ? ? ? ? ? ? ? ? ? ? ? ? 'post_type' => 'post', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'cat' => $category->term_id, ?? ? ? ? ? ? ? ? ? ? ? ? ? ? 'paged' ? ? ? =>? $page ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? query_posts($search_args);?> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <?php while ( have_posts() ) : the_post();?>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <?php $thumb_t = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' ); $url_t = $thumb_t['0'];?>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <li>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <a href="<?php echo get_permalink($post->ID) ?>" alt='<?php the_title() ;?>'> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <?php the_title();?> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </a>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? </li> ? ? ? ? ? ? ? ? ? ? ? ? ? ? <?php endwhile;?>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <div class="clear"></div>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <?php wp_reset_query();? ?> ? ? ? ? ? ? ? ? ? ? ? ? ? </ul> ? ? ? ? ? ? ? ? ? ? </li> ? ? ? ? ? ? ? ? ? <?php endforeach ?> ? ? ? ? ? ? ? ? ? <div class="clear"></div> ? ? ? ? ? ? </ul> ? ? ? </div> </aside>
針對分類頁面列出自定義post分類以及其下的posts
<ul id="list-items"> <p>Categroy</p> ? ? <?php ? ? $taxonomy = 'game_category'; ? ? $terms = get_terms($taxonomy); ? ? foreach($terms as $term) : ? ? ?> ? ? <li> ? ? ? <div class="widget-categories-title"> ? ? ? ? <a href="<?php echo get_term_link($term->slug, $taxonomy); ?>" title="<?php echo $term->name; ?>"> ? ? ? ? ? <?php echo $term->name; ?><i class="icon-caret-down"></i> ? ? ? ? </a> ? ? ? </div> ? ? ? <ul class="widget-categories-children"> ? ? ? ? <?php ? ? ? ? ? ? ? //create a new custom query_posts ? ? ? ? ? ? ? ? ? //get current custom post_type category ? ? ? ? ? ? ? ? ? //get the slug ? ? ? ? ? ? ? ? ? $get_current_slug = $term->slug;? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? global $wp_query; ? ? ? ? ? ? ? query_posts( array( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'post_type' => 'games', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'showposts' => 30, ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'tax_query' => array( ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'relation' => 'AND', ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? array( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'taxonomy' => 'game_category', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'field' => 'slug', ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 'terms' => array( ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? $get_current_slug, ?? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ) ? ? ? ? ? ? ? );? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <?php while ( have_posts() ) : the_post(); ?> ? ? ? ? ? ? ? <li>? ? ? ? ? ? ? ? ? ? ? <a href="<?php echo get_permalink($post->ID) ?>" alt='<?php the_title()?>'> ? ? ? ? ? ? ? ? ? ? <?php the_title()?> ? ? ? ? ? ? ? ? ? </a>? ? ? ? ? ? ? ? </li> ? ? ? ? ? ? ? <div class="clear"></div>? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? <?php endwhile; wp_reset_query();? ?> ? ? ? ? </ul> ? ? ? </li> <?php endforeach ?> <div class="clear"></div> </ul>
限制字?jǐn)?shù)
<?php echo wp_trim_words( get_the_content(), 100 ); // 文章內(nèi)容 echo wp_trim_words( get_the_excerpt(), 100 ); // 文章摘要 echo wp_trim_words( get_the_title(), 100 ); // 文章標(biāo)題 ?> <?php echo substr($category->description,0,160);?> //限制分類定義字?jǐn)?shù)
QQ彈出框
qq:<a href=”http://wpa.qq.com/msgrd?v=3&uin=2755814742&site=qq&menu=yes” target=”_blank”>在線咨詢</a>
雜類
<?php foreach((get_the_category()) as $category){ echo $category->cat_name;}?>?獲取當(dāng)前的分類名稱 single頁面獲取當(dāng)前post的分類以及鏈接 <?php $cats = get_the_category(); foreach( $cats as $cat ) { ?> <a href="<?php echo get_category_link($cat->term_id); ?>"><?php echo $cat->name; ?></a> <?php break; } ?>
子類page獲取父類page的名稱以及鏈接
<a href="<?php echo get_permalink($post->post_parent) ?>"><?php $parent_title = get_the_title($post->post_parent); echo $parent_title; ?></a>
引用百度地圖
<iframe title=”上海瑞深電子科技有限公司” src=”../baidumap.html” width=”100%” height=”300″ frameborder=”0″>上海瑞深電子科技有限公司</iframe>
footer尾部
注明版權(quán),加上工作室鏈接
<a href=”http://www.eastdesign.net/”>Supported by Eastern Design Studio</a>
引入引用js
? ?
<script src="<?php echo get_template_directory_uri(); ?>/js/jquery.min.js"></script> ? ? <script src="<?php echo get_template_directory_uri(); ?>/js/bootstrap.min.js"></script>