Wordpress建站基础教程.docx
- 文档编号:23274930
- 上传时间:2023-05-15
- 格式:DOCX
- 页数:12
- 大小:117.27KB
Wordpress建站基础教程.docx
《Wordpress建站基础教程.docx》由会员分享,可在线阅读,更多相关《Wordpress建站基础教程.docx(12页珍藏版)》请在冰豆网上搜索。
Wordpress建站基础教程
安装源码
需要服务器有php环境(PHP,Mysql,Apeach/Ngnax)
我用的主机宝(环境一键安装工具)
打开后台突然出现这种情况
Brieflyunavailableforscheduledmaintenance.Checkbackinaminute.
这是因为后台在自动更新,需要等待。
(一般等待也无用,一直这样,因为被墙了)
解决办法:
在网站根目录,找到.maintenance了,删除它,就可以了。
Wordpress后台设置
设置->固定链接设置
文章列表页会用到(用于测试,测试完调成正常篇数)
后台插件的删除与安装
删除默认的插件,安装网站用到的插件(AFC插件(高级自定义字段))
问题1:
删除不了默认插件
删除不了默认插件,是因为权限问题。
把wp-content目录的权限设置为“777”,就没问题了
问题2:
添加插件一直打不开,最后超时
修改wp-config.php配置文件,最下边中添加
set_time_limit(0);
对wordpress的最大执行时间无限制
问题3:
发生意外错误,可能WordPress.org或服务器配置文件存在问题。
如果该问题持续发生,请考虑去支持论坛寻求帮助
我ping“wordpress.org,cn.wordpress.org”都是250ms,速度太慢了。
所以出现这个情况。
创建主题的基础架构文件
压缩包在微云,解压上传即可。
网站目录结构,后台的全局变量页,自定义分类都有了。
/*
ThemeName:
Brearing
ThemeURI:
https:
//www.linqing.cc
Author:
Roluce
AuthorURI:
https:
//www.linqing.cc
Description:
thisisthefirsttemplateofroluce.
Version:
1.0
License:
License
LicenseURI:
http:
//www.gnu.org/licenses/gpl-2.0.html
Tags:
Tags
Thistheme,likeWordPress,islicensedundertheGPL.
Useittomakesomethingcool,havefun,andsharewhatyou'velearnedwithothers.*/
php/*
TemplateName:
下载*/
>
准备HTML文件
首页,新闻列表页,新闻内容页,产品列表页,产品内容页,其他单页
我用仿站小工具
复制代码到主题的相关模板页
上传img,css,js
替换html(index.php,category.php,single.php)
img/ => phpechoget_stylesheet_directory_uri()? >/img/ css/ => phpechoget_stylesheet_directory_uri()? >/css/ 提取header和footer phpget_header();? > phpget_footer();? > phpget_sidebar();? > 内容页single.php 开头必须加: phpthe_post();? > ps: 无需循环和query() 导航相关 the_category(',')//在post()下链接+名称($category=get_the_category();$category[0]->cat_name;//获取分类名称$category[0]->term_id//获取分类id get_category_link($category[0]->term_id)//获取分类的链接 get_cat_name($category[0]->parent);//获取父类名称 get_category_link($category[0]->parent);//获取父类的链接 内容相关 the_title()//标题 the_content()//内容 the_ID()//文章ID the_time('Y/n/jG: i: s')//时间the_permalink() the_excerpt()//摘要the_author() phpechoget_avatar(get_the_author_email(),36);? >作者头像 get_the_title() get_the_author_meta('description') 上一篇/下一篇 phpif(get_previous_post()){previous_post_link('上一篇: %link');}else{echo"没有了,已经是最后文章";}? > phpif(get_next_post()){next_post_link('下一篇: %link');}else{echo"没有了,已经是最新文章";}? > 分类页category.php 导航相关 $catid=$cat//本分类页的id phpechoget_category_link($cat);? >//本页分类的链接 phpechoget_cat_name($cat);? >//本页分类的名称 (1) single_cat_title();//本页分类的名称 (2) single_cat_title(”,false); the_category();//链接+名称(尼玛格式化的) $cat_obj=get_category($cat);//本页的父类id $cat_obj->parent, <自定义分类的$cat> $cat_title=single_cat_title('',false);$cats=get_term_by('name',$cat_title,'cat_product');$cat=$cats->term_id; 默认文章分类(调用文章列表) php query_posts("showposts=5&cat=21");//本页不要这句,自定义分类才用while(have_posts()){ the_post();? > phpthe_permalink();? >"target="_blank"> phpthe_title();? > phpthe_time('Y-n-j');? >] php }? > 文章所属分类和链接$cat=get_the_category(get_the_ID()); phpechoget_category_link($cat[0]->term_id);? >"class="news_list_cat"target="_blank">[ phpecho$cat[0]->name;? >] 子分类列表 php//得到所有分类列表 $args=array( 'parent'=>'2', 'hide_empty'=>0,//没文章是否显示 'orderby'=>'ID', 'number'=>'5'//掉用几个分类); $categories=get_categories($args); foreach($categoriesas$cat_item){ ? > phpif($cat_item->cat_ID==$cat)echo"thistab";? >"> phpechoget_category_link($cat_item->cat_ID)? >"> phpecho$cat_item->cat_name;? > php } ? > 调用各分类下的文章 php//query_posts("showposts=5&cat=$cat");//无需这句,不然翻页失效while(have_posts()){ the_post(); $cat=get_the_category(get_the_ID());//本篇文章的分类数组 > phpthe_time('Y/n/j');? > phpthe_title();? >"href=" phpthe_permalink();? >"> [ phpecho$cat[0]->name;? >] phpthe_title();? > php }? > 翻页代码 重点说明: 1: 调用分类下文章时,直接用while(have_posts()){…………}就行。 不必用query_posts("showposts=5&cat=$cat") 因为在category页,如果不指定,默认调用本分类{$cat}遍历文章 2: 下边的翻页代码,php代码部分不用改,只根据页面调整下css样式即可(这里是个小难点) 3: 每页显示多少,由后台的“设置”-->"阅读设置"控制 php the_posts_pagination(array( 'prev_text'=>上页, 'next_text'=>下页, 'before_page_number'=>' 'after_page_number'=>' ));? >
列表页-不同分类id,输出不同的文本
php
$parentid=cate_is_in_descendant_category
(2)?
2:
6;
>
phpecho$parentid==2?
"新闻资讯":
"游戏资料";?
>
php//得到所有分类列表
$args=array('parent'=>$parentid,'hide_empty'=>0,//没文章是否显示//'orderby'=>'ID','number'=>'6'//掉用几个分类
);
$categories=get_categories($args);foreach($categoriesas$cat_item){?
>
phpif($cat_item->cat_ID==$cat)echo"thistab";? >"> phpechoget_category_link($cat_item->cat_ID)? >"> phpecho$cat_item->cat_name;? >
php
}?
>
内容页-不同分类id,输出不同的文本
php
$parentid=post_is_in_descendant_category
(2)?
2:
6;?
>
phpecho$parentid==2?
"新闻资讯":
"游戏资料";?
>
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Wordpress 基础教程