douyou8266 2018-07-08 23:59
浏览 131

无法在wordpress主题上加载自定义CSS

I've created an HTML/CSS design and now I'm trying to convert it to a WordPress template. I've created the stylesheet and function.php.

I have the following code in my function.php

<?php

   function test_theme(){
    wp_enqueue_style("customstyle", get_stylesheet_uri() )



   }

add_action( 'wp_enqueue_scripts', 'test_theme' );

I've added this to my header.php

<?php wp_head(); ?>

For some reason after adding that WordPress has added a few scripts and links to the header but not my custom stylesheet

What am I doing wrong? I'm also new to wordpress development and following a youtube video.

  • 写回答

1条回答 默认 最新

  • dsg41888 2018-07-09 03:14
    关注

    How to create a wordpress theme from scratch:

    1. Create your theme folder in the wp-content/themes/yourtheme
    2. Create an index.php file in your theme folder
    3. Create your stylesheet style.css in your theme folder
    4. Place your code in the index.php file according to the wordpress rules

      <?php get_header(); echo "<h2>This is the index</h2>"; get_sidebar(); get_footer(); ?>

    5. Place your CSS in the style.css according to the wordpress rules. Usually we add this at the top of the style.css so that you no longer have to enqueue it in the functions.php

    /*
     * Theme Name: Your theme
     * Theme URI: https://yourtheme.com
     * Author: Memyself Andi
     * Author URI: https://yourtheme.com
     * Description: My WordPress theme.
     * Version: 1.0
    */

    Now go into your wordpress install and go to Dashboard > Appearance > Themes > Activate "Your theme"

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器