多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
wp主题文件夹下最基本需要: index.php, style.css 出现无法选择主题的时候,可以在wordpress根目录的index.php上加上这句 ~~~ define( 'WP_MEMORY_LIMIT', '256M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' ); ~~~ charset=UTF-8 `charset=<?php bloginfo('charset');?>` wp的主题绝对路径: `<?php bloginfo('template_directory'); ?>` 或者: `<?php echo esc_url(get_template_directory_uri()); ?>` wp主题下的style.css文件的路径 `<?php bloginfo('stylesheet_url');?>` wp首页路径 `<?php echo get_option('home'); ?>` 网站名字 `<?php bloginfo('name'); ?>` 主题的标题和描述: `<title><?php bloginfo('name'); ?> | <?php bloginfo('description'); ?></title>` 或者wp默认标题和描述样式: ~~~ // 无title标签情况下有: <?php wp_head(); ?> // 在funtions.php加入: <?php add_theme_support( 'title-tag' ); ?> ~~~ 修改静态页面的css、js、img等文件夹位置为wp文件时,可以搜索css/、js/、img/,然后替换为: ~~~ <?php bloginfo('template_directory'); ?>/css/ <?php bloginfo('template_directory'); ?>/js/ <?php bloginfo('template_directory'); ?>/img/ ~~~ 这样可以避开某个单词下的css、js、img等字母,直接搜索后续为css/、js/、img/的文件夹进行替换。 调用头部、侧边栏、尾部,其他页面 ~~~ <?php get_header();?> <?php get_sidebar();?> <?php get_footer();?> // load other_page.php <?php get_template_part('other_page'); ?> ~~~ 消除插件的兼容性问题 ~~~ <?php wp_head(); ?> <?php wp_footer();?> ~~~ function.php调用导航栏 ~~~ <?php //自定义菜单 register_nav_menus( array( 'header-menu' => __( '导航自定义菜单' ), ) );?> ~~~ 页面调用导航栏 `<?php wp_nav_menu( array( 'container' => '','menu_class' => 'navigation','menu_id' => 'nav_sgBhgn') ); ?>` 注册特色图片功能 ~~~ <?php function theme_setup(){ //add featured image support add_theme_support('post-thumbnails'); } add_action('after_setup_theme','yunfan_setup'); ~~~ 友情链接只在首页显示 ~~~ <?php if ( is_home()) { ?> <?php wp_list_bookmarks('title_li=&categorize=0&orderby=rand&limit=24'); ?> <?php } ?> ~~~ 找回3.5版本后隐藏的友链管理功能,在函数文件functions.php,粘贴以下代码: `<?php add_filter( 'pre_option_link_manager_enabled', '__return_true' ); ?>` 显示文章特色图和内容 ~~~ <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="words"> <p> <?php the_post_thumbnail();?> <?php the_content("");?> </p> </div> <?php endwhile; ?> <?php endif; wp_reset_query(); ?> ~~~