学做网站培训课程介绍

当前位置:

网站后台怎么做(网站后端开发方法)

网站后台又称网站后端,它是用来控制网站的管理系统。对于制作网站后台,我们常用的方法就是通过安装WordPress用户注册登录会员中心插件(组件)来生成网站后台。然后在基本后台的基础上进行后台开发。

网站后台

学做网站论坛的建站培训课程中也有专门讲解网站后台开发制作的方法。下面是我们常用的网站后台开发的操作。

第1节:后台菜单的注册、调用

1-1、 在函数文件functions.php文件中添加以下代码;


//添加菜单功能
if (function_exists('add_theme_support')) {
add_theme_support('nav-menus');
register_nav_menus( array( 'primary' => __( 'Primary Navigation', 'primary' ) ) );
}

1-2、 调用添加的菜单;


<?php wp_nav_menu( array( 'container' => '','menu_class' => 'navigation','menu_id' => "nav_sgBhgn",'depth' => 2, ) ); ?>

第2节:后台多菜单功能的注册、调用和使用

1、在函数文件functions.php文件中添加以下代码;


//添加多个菜单功能
if ( function_exists('register_nav_menus')) {register_nav_menus(array('topmenu' => ' 顶部菜单'));}
if ( function_exists('register_nav_menus')) {register_nav_menus(array('footmenu' =>'底部菜单'));}

2、分别调用代码:


<?php wp_nav_menu( array( 'theme_location' =>'topmenu','container' => '','menu_class' => 'navigation','menu_id' => "nav_sgBhgn",'depth' => 2, ) ); ?>

添加CSS样式


#footer li{width:80px;float:left;margin-right:10px}

第3节:后台小工具的制作和调用

1-1、在functions.php中添加小工具注册代码:


//添加小工具功能
if ( function_exists('register_sidebar') )
register_sidebar(array(
'before_widget' => '<li>',
'after_widget' => '</li>',
'before_title' => '<h2>',
'after_title' => '</h2>',
));

1-2、侧边栏调用小工具;


<!--判断开始-->
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<?php endif; ?>
<!--判断结束-->

第4节:添加自定义小工具模块

1、制作小工具模块 热门文章调用:


<li>
<h2>热门文章</h2>
<ul>
<?php $popular = new WP_Query('orderby=comment_count&posts_per_page=10'); ?>
<?php while ($popular->have_posts()) : $popular->the_post(); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
</li>

最新评论调用:


<li>
<h2>最新评论</h2>
<ul>
<?php
global $wpdb;
$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID, comment_post_ID, comment_author, comment_date_gmt, comment_approved,comment_author_email, comment_type,comment_author_url, SUBSTRING(comment_content,1,25) AS com_excerpt FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' AND comment_author != 'admin' AND post_password = '' ORDER BY comment_date_gmt DESC LIMIT 7";
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
foreach ($comments as $comment) {
$output .= "\n<li>".strip_tags($comment->comment_author)
."回复说:" ."<a rel='nofollow' href="" . get_permalink($comment->ID) . "#comment-" . $comment->comment_ID . "" title="" . $comment->post_title . " 上的评论">". strip_tags($comment->com_excerpt) ."</a></li>";
}
$output .= $post_HTML;
$output = convert_smilies($output);
echo $output;
?>
</ul>
</li>

2、在functions.php文件中注册小工具模块:


if( function_exists( 'register_sidebar_widget' ) ) {
register_sidebar_widget('热门文章模块','mb_hot');
register_sidebar_widget('最新评论模块','mb_comments');
}

3、在functions.php文件中调用新添加的小工具模块


function mb_hot() { include(TEMPLATEPATH . '/remen.php'); }
function mb_comments() { include(TEMPLATEPATH . '/pinglun.php'); }

第5节:网站后台添加在线客服

  • 1、免费js网站下载特效代码;
  • 2、集成代码到主题中。
  • 3、图片路径的补充完整:
    
    
    <?php bloginfo('template_directory'); ?>/kf/images/

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

相关教程

  • 之前有很多建网站学员反映,自己学习了wordpress教程,制作了网站,但有时会碰到wordpres后台无法登录,密码确认无误,空间没有问题,之前也成功登录
  • 忘记后台登录密码是自己建网站学员经常犯的错误,如果在使用wordpress程序建网站时,忘记了后台管理员登陆密码要如何解决?下面学做网站论坛
  • DW图文混排怎么做 视频教程附件下载 (1163969 次浏览)
    课程中的案例网页下载:xwz.rardreamweaver 图文混排使用dreamweaver 图文混排,插入图片的时候会有一个对齐的选项,如左对齐,就是图片在左侧,
  • 自己怎么做一个机械公司网站,此款机械公司网站第一感觉就是干净,大方。使用的范围很广,可以用于机械公司企业站点使用。机械公司网站首页超大幻
  • 自己做的一个房产开发企业网站,制作过程全部按照课程里学习的知识操作的,如果喜欢的同学,可以留言。大家在使用的时候,网站首页更多按钮需要自
  • 青海茂祥房地产开发公司成立于1984年,    1988年进入房地产行业,经过三十余年的发展,成为国内领先的房地产公司,目前主营业务包括房地产开发和物业
  • 网站后台又称网站后端,它是用来控制网站的管理系统。对于制作网站后台,我们常用的方法就是通过安装WordPress用户注册登录会员中心插件(组件)来生