将静态的模板文件保存到wp-content/tust。保存的首页default.html和其他的文件目录如下:

然后建立标准的wp文件。例如:www.qihanghao.cn 里的。如下图所示:

将default.html分割到header.php, index.php, footer.php

header.php 包含body再内的导航栏,等下还会贴出修改后的代码。

index.php 包含主体部分,要引用header.php 和 footer.php。

footer.php 包含最后的版权等信息。

style添加主题版权信息:

 /*
Theme Name: 我的模板A1
Theme URI: https://www.cnmeizhuang.com
Description:我的模板A1 XX主题
Author: 我的模板A1
Author URI: https://www.cnmeizhuang.com
Version: 1.0
Tags: 我的模板A1
*/
---------------------

wordpress调用一些想用的调用:

Style.css路径调用:<?php bloginfo( 'stylesheet_url' ); ?>
jS调用:<?php echo get_template_directory_uri(); ?>/js/jquery.js
调用顶部标签:<?php get_header();?>
调用底部标签:<?php get_footer();?>
底部菜单调用:<?php wp_nav_menu( array( 'theme_location' =>'footmenu','container' => '','menu_class' => 'navigation','menu_id' => "nav_sgBhgn",'depth' => 2, ) ); ?>
版权信息:Copyright © 2012<a href=" <?php echo get_option('home'); ?>"> <?php bloginfo('name'); ?></a>
缩略图的调用:<img src="<?php echo get_first_image(); ?>" alt="<?php the_title(); ?>" />
网站标题:<?php if (is_home()||is_search()) { bloginfo('name'); } else { wp_title(''); print " - "; bloginfo('name'); } ?>
HOOK函数:<?php wp_head(); ?>
网站域名地址:<?php bloginfo('url');?>
获取主题目录://第一种方法<?php bloginfo('template_url');?>//第二种方法<?php bloginfo('template_directory'); ?>//第三种方法<?php echo get_template_directory_uri(); ?>
调用侧边栏标签:<?php get_sidebar();?>
调用特定分类下的文章:直接复制到要显示分类的地方。cat=1为id=1下面的文章,showposts=5为显示5片文章。<?php if (have_posts()) : ?><?php query_posts('cat=1' . $mcatID. '&caller_get_posts=1&showposts=5'); ?><?php while (have_posts()) : the_post(); ?><?php endwhile;?><?php endif; wp_reset_query(); ?>
文章标题的调用(控制字数):<a href="<?php the_permalink() ?>"> <?php echo mb_strimwidth(get_the_title(), 0, 32, ''); ?></a>
标题不控制字数:<?php the_title(); ?>
更多按钮链接,直接进入该分类页面地址调用::<?php echo get_option('home'); ?>/?cat=1
产品树形结构调用: <?php wp_list_categories('title_li=0&orderby=name&show_count=0&depth=3'); ?>友情链接只在首页显示:
<?php  if ( is_home()) { ?>
<?php wp_list_bookmarks('title_li=&categorize=0&orderby=rand&limit=24'); ?>
<?php } ?>分页代码:<?php kriesi_pagination($query_string); ?>---------www.cnmeizhuang.com------------ 

--------------------- ------------------------------------

2.修改header.php中的链接使首页正常。其中常用的模板函数:

基本条件判断函数:is_home():是否为主页is_single():是否为内容页 (Post)is_page():是否为内容页 (Page)is_category():是否为 Category/Archive 页is_tag():是否为标签 (Tag) 存档页is_date():是否为指定日期存档页is_year():是否为指定年份存档页is_month():是否为指定月份存档页is_day():是否为指定日存档页is_time():是否为指定时间存档页is_archive():是否为存档页is_search():是否为搜索结果页is_404():是否为 "HTTP 404: Not Found" 错误页is_paged():主页 /Category/Archive 页是否以多页显示Header 部分常用到的 PHP 函数:<?php bloginfo('name'); ?>:博客名称 (Title)<?php bloginfo('stylesheet_url'); ?>:CSS 文件路径<?php bloginfo('pingback_url'); ?>:PingBack URL<?php bloginfo('template_url'); ?>:模板文件路径<?php bloginfo('version'); ?>:WordPress 版本<?php bloginfo('atom_url'); ?>:Atom URL<?php bloginfo('rss2_url'); ?>:RSS 2.o URL<?php bloginfo('url'); ?>:博客 URL<?php bloginfo('html_type'); ?>:博客网页 HTML 类型<?php bloginfo('charset'); ?>:博客网页编码<?php bloginfo('description'); ?>:博客描述<?php wp_title(); ?>:特定内容页 (Post/Page) 的标题模板常用的 PHP 函数及命令:<?php get_header(); ?>:调用 Header 模板<?php get_sidebar(); ?>:调用 Sidebar 模板<?php get_footer(); ?>:调用 Footer 模板<?php the_content(); ?>:显示内容 (Post/Page)<?php if(have_posts()):?>:检查是否存在 Post/Page<?php while(have_posts()):the_post(); ?>:如果存在Post/Page则予以显示<?php endwhile; ?>:While 结束<?php endif; ?>:If 结束<?php the_time('字符串') ?>:显示时间,时间格式由"字符串"参数决定,具体参考 PHP 手册<?php comments_popup_link(); ?>:正文中的留言链接,如果使用 comments_popup_script(); 则新窗口打开链接<?php the_title(); ?>:内容页 (Post/Page) 标题<?php the_permalink() ?>:内容页 (Post/Page) URL<?php the_category(',') ?>:特定内容页 (Post/Page) 所属 Category<?php the_author(); ?>:作者<?php the_ID(); ?>:特定内容页 (Post/Page) ID<?php edit_post_link(); ?>:如果用户已登录并具有权限,显示编辑链接<?php get_links_list(); ?>:显示 Blogroll 中的链接<?php comments_template(); ?>:调用留言/回复模板<?php wp_list_pages(); ?>:显示 Page 列表<?php wp_list_categories(); ?>:显示 Categories 列表<?php next_post_link('%link '); ?>:下一篇文章链接<?php previous_post_link('%link'); ?>:上一篇文章链接<?php get_calendar(); ?>:日历<?php wp_get_archives() ?>:显示内容存档<?php posts_nav_link(); ?>:导航,显示上一篇/下一篇文章链接<?php include(TEMPLATEPATH . '/文件名'); ?>:嵌入其他文件,可为定制的模板或其他类型文件与模板相关的其他函数:<?php _e('Message'); ?>:输出相应信息<?php wp_register(); ?>:显示注册链接<?php wp_loginout(); ?>:显示登录/注销链接<!–next page–>:将当前内容分页<!–more–>:将当前内容截断,以不在主页/目录页显示全部内容<?php timer_stop(1); ?>:网页加载时间(秒)<?php echo get_num_queries(); ?>:网页加载查询量
---------------------
作者:www.nongyejing.com

将模板中的css,js,图片的链接都换成上面的函数

3.页面显示正常时,进行导航栏的修改。

其中导航栏设置时,修改原始代码:

使用wp_nav_menu进行代替,菜单导航的代码,如图下注释的部分,将所有的菜单都进行注释。其中代换时,遵循下面的参数。

<?php wp_nav_menu(
array(
'theme_location'  => '' //指定显示的导航名,如果没有设置,则显示第一个
'menu'            => 'header-menu',
'container'       => 'nav', //最外层容器标签名
'container_class' => 'primary', //最外层容器class名
'container_id'    => '',//最外层容器id值
'menu_class'      => 'sf-menu', //ul标签class
'menu_id'         => 'topnav',//ul标签id
'echo'            => true,//是否打印,默认是true,如果想将导航的代码作为赋值使用,可设置为false
'fallback_cb'     => 'wp_page_menu',//备用的导航菜单函数,用于没有在后台设置导航时调用
'before'          => '',//显示在导航a标签之前
'after'           => '',//显示在导航a标签之后
'link_before'     => '',//显示在导航链接名之后
'link_after'      => '',//显示在导航链接名之前
'items_wrap'      => '<ul id="%1$s">%3$s</ul>',
'depth'           => 0,显示的菜单层数,默认0,0是显示所有层
'walker'          => ''// //调用一个对象定义显示导航菜单 ));
?>  

其中首页header.php修改完成后,大致如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /><title>XX学院</title><meta name="keywords" content="XX学院" /><meta name="description" content="<?php bloginfo('description'); ?>" /><link rel="shortcut icon" type="image/ico" href="<?php echo get_option(' wpd_logo '); ?>" />
<link href="<?php bloginfo('template_url'); ?>/css/reset-min.css" rel="stylesheet" type="text/css" />
<link href="<?php bloginfo('template_url'); ?>/css/fonts-min.css" rel="stylesheet" type="text/css" />
<link href="<?php bloginfo('template_url'); ?>/css/grids-min.css" rel="stylesheet" type="text/css" />
<link href="<?php bloginfo('template_url'); ?>/css/common.css" rel="stylesheet" type="text/css" />
<script src="<?php bloginfo('template_url'); ?>/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<!--[if lt IE 7]>
<script src="js/ie7.js"></script>
<![endif]-->
<script type="text/javascript" src="js/iepngfix_tilebg.js"></script>
<link href="<?php bloginfo('template_url'); ?>/css/index.css" rel="stylesheet" type="text/css" /><link href="<?php bloginfo('template_url'); ?>/css/frame-top-link.css" rel="stylesheet" type="text/css" /><link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/mainmenu.css" /><link href="<?php bloginfo('template_url'); ?>/css/jqueryslidemenu.css" rel="stylesheet" type="text/css" /><link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/bigpic.css" /><link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/modulelist.css" /><link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/pager.css" /><script src="<?php bloginfo('template_url'); ?>/js/jquery.slidemenu.js" type="text/javascript"></script><script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/xmosaic.js"></script><script src="<?php bloginfo('template_url'); ?>/js/jquery.js" type="text/javascript"></script><script src="<?php bloginfo('template_url'); ?>/js/kandytabs.pack.js" type="text/javascript"></script><script src="<?php bloginfo('template_url'); ?>/js/custom.js" type="text/javascript"></script><link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/css/footer.css" />
<style>
.tag_description
{float: left;margin-top:7px;padding-bottom:5px;list-style:none;
}.tag_description a{font-size: 12px;text-indent: 24px;}.tag_description p{font-family:"宋体",Verdana, Lucida, Arial, Helvetica;color: #666666;float:right;width:220px;line-height:24px;font-size: 12px;text-indent: 24px;text-align:justify; margin-top:0px;text-justify:inter-ideograph;}#AcadeInfoList{position:relative;top:-20px;}#AcadeInfo_spliter{position:relative;top:10px;}#AcadeInfoList:nth-of-type(n){position:relative;top:0px;}#AcadeInfo_spliter:nth-of-type(n){position:relative;top:30px;}
.tag_title{line-height:24px;background-position-x: 0%;background-position-y: -540px;background-repeat: no-repeat;overflow-x: hidden;width:370px;
}
.tag_title a{color: #666666; font-size:12px; margin-left:0px; padding-left:5px; }</style>
</head>
<body>
<div id="frame-top"><div id="frame-top-warpper"><div class="frame-top-link"><ul><li class="first"><a target="" href="http://www.cnmeizhuang.com">学院首页</a></li><li class=""><a target="" href="/7db3dc.html">联系我们</a></li><li class=""><a target="_blank" href="/admin.html">管理员入口</a></li>  </ul>
</div>
<div id="frame-top-logo"><table><tr><td  style="vertical-align:top"><a href="/" title="XX学院"><img src="<?php bloginfo('template_url'); ?>/picture/2015-09-16-19-7642419411.png" /></a></td></tr></table>
</div>
<div id="frame-top-navbar"><script type="text/javascript">$(document).ready(function () {mlddminit(375);});</script><div id="navbar-left"></div><?php wp_nav_menu( array( 'container' => 'div','container_id' => 'navbar-middle','menu_class' => 'mlddm') ); ?><!--<ul class="mlddm" params="1,-1,500,slide,200,h"><li class=""><a href="#" target="">学院概况</a><ul><li><a href='/01589e.html' target="">学院简介</a></li><li><a href='http://www.cnmeizhuang.com/cbc95b.html' target="">历史沿革</a></li><li><a href='http://www.cnmeizhuang.com/1ab539.html' target="">学院领导</a></li><li><a href='http://www.cnmeizhuang.com/ad9daf.html' target="">学院党委</a></li><li><a href='http://www.cnmeizhuang.com/0c2b70.html' target="">职能部门</a></li><li><a href='#' target="">学术机构</a></li>    替换这里第一条的东西。 --><div id="navbar-right"></div>
</div>
<?php wp_head(); ?>

4.修改index.php中的

这里先进行轮播图的修改,后台进行自我订制了一份代码,如果有想要的化,可以联系我,其中轮播图修改后的代码如下:

<?php get_header(); ?>
<div id="frame-top-slider-detail"> </div><div id="frame-top-slider" class="smallslider"><!-- 大图轮播--><script type="text/javascript">$(document).ready(function () {var l=$('#bigpic').children().length;var str='';for(var i=0; i < l;i++){if(i==0)str += '<li  class="on" ></li>';elsestr += '<li class=" "></li>';}$('#pager').html(str);var mosaic = XMosaic('bigpic', { pager: 'pager', delay: 10000, countX: 10, countY: 5, how: 9, order: 0 });});</script><div  id ="bigpic"><a style="left: 0px; top: 0px; position: absolute;" target="_blank" href="/13v0to-1.html"><img src='<?php echo get_option(' wpd_banner1 '); ?>' alt='1' />
</a><a style="left: 0px; top: 0px; position: absolute;" target="_blank" href=""><img src='<?php echo get_option(' wpd_banner2 '); ?>' alt='2' />
</a>          </div></div></div>

然后修改文章的列表部分:

 <div id="frame-top-slider-mask"><ul class="ctrls" id="pager"></ul></div>
</div>
<div id="frame-main-body"><div id="frame-main-wrapper" class="yui3-g"><div id="frame-main" class="yui3-u"><div id="frame-main-left" class="yui3-u-1-2"><div class="module module_left"><div class="module-name"><a href="/75d14e-1.html" target="_blank">学院新闻</a><a style="font-size:13px; margin-left:250px; color:blue;" target="_blank" href="/75d14e-1.html">更多</a></div><div class="module-spliter"><div> </div></div><div class="module-warpper"><div><div class="row pd5 fb"><a target="_blank" title="信息中心" href="/lqpmfv.html">信息中心</a></div><li class="row spic tag_description"><a target="_blank" href="www.zhuanfang.org/lqpmfv.html" title="信息中心"><img width=360 height="150" align="left" alt="信息中心" src="<?php bloginfo('template_url'); ?>/picture/540_225.jpg"></a></li><div style="clear:both;"></div>
</div>                        <table cellspacing="0" cellpadding="0" class="tag_table"><tbody><?phpquery_posts(//'query_type = post&posts_per_page=8'array ( 'category_name' => 'business', 'posts_per_page' => 8 ));$i=0; while(have_posts()) : the_post(); $i++; ?><tr><td width="100%"><ul><li class="tag_title"><a target="_blank" title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li></ul></td></tr>              <?php endwhile; wp_reset_query(); ?>  </tbody>
</table>                  </div></div></div><div id="frame-main-right" class="yui3-u-1-2"><div class="module"><div class="module-name"> <a href="www.zhuanfang.org/c6c7e7-1.html" target="_blank">通知公告</a><a style="font-size:13px; margin-left:250px; color:blue;" target="_blank" href="/c6c7e7-1.html">更多</a></div><div class="module-spliter"><div> </div></div><div class="module-warpper"><table cellspacing="0" cellpadding="0" class="tag_table"><tbody><?phpquery_posts(//'query_type = post&posts_per_page=8'array ( 'category_name' => 'technolo', 'posts_per_page' => 8 ));$i=0; while(have_posts()) : the_post(); $i++; ?>          <tr><td width="100%"><ul><li class="tag_title"><a target="_blank" title="<?php the_title(); ?>" href="<?php the_permalink(); ?>"><?php the_time('Y年n月j日'); ?>  <?php the_title(); ?></a></li></ul></td></tr><?php endwhile; wp_reset_query(); ?> </tbody>
</table>                  </div></div></div></div><div id="frame-side" class="yui3-u"><div id="placehoder"></div><ul><li><a target="" href="/906368.html">研究成果</a></li><li><a target="" href="/faef50-1.html">学术交流</a></li><li><a target="_blank" href="http://www.zhuanfang.org">实践教学</a></li><li><a target="" href="/ccac59.html">教学成果</a></li><li><a target="" href="/4d3baa-1.html">学生资助</a></li><li><a target="" href="/801d37-1.html">校友相聚</a></li><li><a target="" href="#">学术报告</a></li>           </ul></div></div><div id="frame-main-link" class="yui3-g"><div><div id="demo" style="overflow:hidden;height:110px;margin:0 auto;"><table align="left" cellpadding="0" cellspace="0" border="0"><tr><td id="demo1" valign="top"><div><a style="width:0px;" href="/0c8a9f.html#ppzy" target="_blank"><img src="<?php bloginfo('template_url'); ?>/picture/57243dbb36ec49fe8ea8839a947fe310.jpg" /></a><img src="<?php bloginfo('template_url'); ?>/picture/869b86dfeae34a31b851fb01cec2b074.jpg" /><a style="width:0px;" href="http://www.zhuanfang.org" target="_blank"><img src="<?php bloginfo('template_url'); ?>/picture/2015-08-27-20-0606158108.jpg" /></a><img src="<?php bloginfo('template_url'); ?>/picture/39bfa2a5c9be4d87bb8c50a886d3f3c0.jpg" /></div></td><td id="demo2" valign="top"> </td></tr></table></div></div></div>
</div>
<?php get_footer(); ?>

修改后显示成上图所示,文章换成了 后台上传的文章。

本人整理:企业号

转载:https://blog.csdn.net/cnpinpai/article/details/84575139

wordpress仿站实战教程:wordpress调用函数记录相关推荐

  1. wordpress仿站笔记

    最近接了一个用wordpress仿站的项目,本以为很简单,但实际上手后才发现了一些"小"问题,而且中文网上关于wordpress的教程不仅少,而且老,很多都已经不适用于5.x后的版 ...

  2. Dede仿站系列教程

    织梦仿站系列教程第一讲--准备工作 http://www.cnzhanzhang.com/thread-271370-1-2.html 织梦仿站系列教程第二讲--首页框架 http://www.cnz ...

  3. 织梦仿站系列教程第四讲——首页页首代码

    织梦仿站系列教程第四讲--首页页首代码 今天,我们接上一讲,继续开始我们的仿站之路. 这一讲分两个部分,第一部分,修改首页的页首代码,即之间的代码. 有网页标题title.网页关键字keywords. ...

  4. 织梦仿站系列教程第二十三讲——列表页制作(二)

    织梦后台提示用户名不存在 查看数据库用户名被改为spider 织梦仿站系列教程第二十三讲--列表页制作(二) 这一讲,我们讲下列表页的分页代码,先找到如下代码: 865 1 href="ht ...

  5. 织梦仿站系列教程第二十一讲——封面页制作(四)

    织梦搜索提示关键词不少于2个字节 织梦仿站系列教程第二十一讲--封面页制作(四) 看拳击在线的代码,晕,最新新闻和热门新闻竟然是JS调用,我们只好找到这个JS文件,转换成HTML,然后修改. 将如下代 ...

  6. 织梦仿站系列教程第十一讲——幻灯片的制作

    织梦仿站系列教程第十一讲--幻灯片的制作 我们还是顺着做吧,这一讲说说幻灯片代码的制作. 首先打开index.htm文档,找到幻灯片部分的代码.dedecms教程就是下面这段代码: <DIV i ...

  7. 视频教程-SharePoint Online 建站实战教程(上)-Office/WPS

    SharePoint Online 建站实战教程(上) 大家好,我是霖雨,从2010年开始致力于SharePoint相关的技术研究,精通SharePoint环境搭建.实施.开发.运维.排错等相关技术, ...

  8. wordpress建站基本教程 全了 菜鸟也会建站了!!

    总目录 1.WordPress是什么? 2.WordPress详细安装教程 3.WordPress常规基本设置 4.wordpress主题模板安装 5.WordPress插件安装 6.wordpres ...

  9. wordpress建站准备教程(一)域名:域名备案、域名注册、域名绑定、域名解析

    第一章.简介 WordPress建站的起点,首先要进行域名进行相关的操作(比如域名注册),然后才到.若是详细对域名进行详细阐述,又可以分为域名备案.域名注册.域名绑定.域名解析. 你可以会注意到,我下 ...

最新文章

  1. java lucene demo,lucene自带的两个demo的运行测试方法
  2. mysql ddl dcl_MySQL常用DDL、DML、DCL语言整理(附样例)
  3. Java中判断List中是否有重复元素
  4. idea配置远程服务器实现远程编辑文件及ssh连接
  5. Boost:基于Boost的stream流服务器
  6. Lnmp环境安装禅道项目管理软件
  7. java课程设计实验报告_javaweb课程设计实验报告
  8. 电压放大倍数公式运放_模电的半壁江山——运算放大器的原理和应用
  9. 微信公众号开发相关流程及功能介绍
  10. 兜兜转转躲不命运轮回---Java基础学习笔记3
  11. 手写sql语句面试题
  12. 如何用浏览器测试post请求
  13. 「六一端午」双节|营销人必看的新玩法
  14. Kafka扩分区和分区副本重分配之后消费组会自动均衡吗?
  15. ANSI与UTF-8区别
  16. 使用opencv检测视频人脸
  17. 啥是BGP机房啊,被科普一下!
  18. 智慧城市八大应用,助力城市更加智慧
  19. configure: error: Package requirements (libzip >= 0.11 libzip ≠ 1.3.1 libzip ≠ 1.7.0) were not met
  20. VM ware15安装MacOS 10.14

热门文章

  1. 计算机动漫设计需要学什么,计算机动画制作专业好学吗?都有哪些课程?
  2. 常见的几种服务器/客服端模型
  3. Java实现邮箱发送验证码(以QQ邮箱为例)
  4. 6月2亚欧盘黄金走势分析交易策略小心空头反击高位谨慎追多
  5. vue手脚架生成vue项目(个人笔记)
  6. WC 2018 冬眠记
  7. InnoDB: Running in read-only mode 问题排查
  8. reactjs前端数据导出
  9. php 查看nts,查看php是ts还是nts的方法
  10. php扩展ts和nts,浅谈php的TS和NTS的区别