您的位置 >>> 星想互联 >>> 网站建设 >>> 建站知识
单页主题WordPress制作视频教程下载
点击数:4229  发布时间2015-02-12 12:57:59
相信学习SEO的同学有好多是从淘宝客开始的,武汉网站建设公司也是如此,刚开始想做着玩玩,赚些零花钱,根本没想到SEO的知识不是一朝一夕能够学完的。在刚开始做的时候,不知道如何建站,做淘客也非常的累,那么这个教程可以教大家如何用WordPress做一个单页主题的模板,学了这个教程,就可以非常容易的对淘客站甚至企业站进行熟练的操作了。
1、wordpress模板结构分析
索引页模版:index.php顶部:header.php
文章页面模板:single.php
边栏模板:sidebar.php
底部:footer.php
页面模版:page.php
搜索结果:search.php
文章归档:archive.php
评论:comments.php
404 页面模版:404.php
主题支持函数:functions.php
样式表:style.css
2、制作一个可以运行的wordpress主题,修改style.css
制作一个最简单的主题,只需要两个文件,index.php和style.css
第一步,准备静态页面
第二步,制作index.php和style.css
第三步,给style.css添加版权信息
第四步:把主题上传到空间中wordpress安装路径,wp-content/themes/下面,这里主题的文件夹名字必须是英文
第五步,在wordpress后台启用主题
先给style.css添加版权信息
/*
Theme Name: wordpress theme 01
Theme URI: http://www.wpbaike.com
Description: a simple bolg theme
Author: xixi
Author URI: http://www.wpbaike.com
Version: 1.0
Tags: white, blog, liweihui, blue
*/
Style.css路径调用:<?php bloginfo( ‘stylesheet_url’ ); ?>
主题缩略图名字:screenshot.png
3、制作出主题结构,index.php,header.php,footer.php,sidebar.php
把index.php拆分成header.php,footer.php和sidebar.phhp
<?php get_header();?>
<?php get_footer();?>
<?php get_sidebar();?>
4、修改header.php,footer.php
新建一个index.php文件,header.php,footer.php,
这步需要用到的标签:
获取博客名字:<?php bloginfo(‘name’); ?>
获取博客描述:<?php bloginfo(‘description’); ?>
获取主页路径:<?php echo get_option(‘home’); ?>
获取主题存放路径:<?php bloginfo(‘template_directory’); ?>
其他外部文件调用方法:<?php include (TEMPLATEPATH . ‘/ad/ad2.htm’); ?>
编码标签调用:<meta http-equiv=”Content-Type” content=”text/html; charset=<?php bloginfo( ‘charset’ ); ?>” />
<?php wp_head(); ?>
标题调用:<title><?php if (is_home()||is_search()) { bloginfo(‘name’); } else { wp_title(”); print ” – “; bloginfo(‘name’); } ?> </title>
页面调用:
<?php wp_list_pages(‘sort_column=menu_order&title_li=&depth=2&include=’); ?>
分类目录调用:
<?php wp_list_categories(‘title_li=0&orderby=name&show_count=0&depth=2′); ?>
5、制作sidebar.php
最新文章:<?php wp_get_archives(‘type=postbypost&limit=20′); ?>
日志标题太长超出,修改style.css,用到的代码:
text-overflow:ellipsis; white-space:nowrap; overflow:hidden;
随机文章:
<?php $rand_posts = get_posts(‘numberposts=10&orderby=rand’);foreach($rand_posts as $post) : ?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php endforeach;?>
标签云:
<?php wp_tag_cloud(‘smallest=8&largest=36&’); ?>
文章日期归档:
<?php wp_get_archives( ‘type=monthly’ ); ?>
分类目录:
<?php wp_list_cats(‘sort_column=name&optioncount=1&hierarchical=0′); ?>
友情链接:
<?php wp_list_bookmarks(‘title_li=&categorize=0&orderby=rand&limit=24′); ?>
6、制作index.php
文章循环标签:
循环开头:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
循环结尾:
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
标题:<a href=”<?php the_permalink() ?>”><?php the_title_attribute(); ?></a>
调用文章内容:
<?php the_content(“Read More…”); ?>
调用文章内容摘要:
<?php the_excerpt(“Read More…”); ?>
作者:<?php the_author_posts_link(); ?>
日期:<?php the_time(‘F d, Y’) ?>
评论调用:<?php comments_number(‘No Comment’, ‘1 Comment’, ‘% Comments’ );?>
文章所属分类:标签:<?php the_category(‘, ‘) ?>
上一页,下一页调用:
<div style=”float:left”><?php previous_post_link(‘&laquo; %link’); ?></div>
<div style=”float:right”><?php next_post_link(‘%link &raquo;’); ?></div>
7、制作single.php页面,加入评论
在single.php中调用<?php endwhile; ?>和<?php else : ?>中间让入
<?php comments_template(); ?>
8、制作page.php,archive.php,404.php
Page.php和single.php一样
archive.php和index.php一样
9、制作小工具
添加functions.php,
<?php
if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘before_widget’ => ‘<div class=”sidebox”>    ‘,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’,
));
?>
在sidebar.php中模块最上面插入:
<?php if ( !function_exists(‘dynamic_sidebar’)
|| !dynamic_sidebar() ) : ?>
Sidebar最下面,添加<?php endif; ?>
10、细节问题处理
分页的函数:加到functions.php中
大家在学习这些内容的过程中,千万不要光看不练,因为建站是个操作性比较强的东西,在听的时候感觉挺简单的,都能听懂,但是当你真正自己操作的时候会发现很多问题,这些问题只有不断的修改尝试才能熟练的掌握,很多同学没有自己的空间和域名,这不要紧,武汉网站建设公司写过一篇《本地网站测试服务器搭建视频教程下载》,大家可以学习在本地环境上对模板进行修改,这样既省时又不用花钱。
来源:武汉网站建设