dongzheng8463 2014-08-27 04:03
浏览 49
已采纳

wordpress-add code to function.php

i want to create my first theme. i added my codes in header.php and function.php but my theme doesn't know i added function.php to my theme at all! here the codes in function.php:

<?php
    DEFINE("THEME_LOC",get_template_directory_uri() );
    remove_action('wp_head','wp_generator');
    function enq_style(){
        wp_register_style('style',THEME_LOC.'/style.css',array(),'1','all',false);
        wp_enqueue_style('style');
    }
    add_action('wp_enqueue_scripts','enq_style');
?>

when i call THEME_LOC from header.php. it doesn't know i stored my theme location into this constant. what's the problem? shall i include my function.php into my theme or something? i've got another question too. does style.css add to my theme automatically or i have to register that style to my theme like what i did in fucntion.php?

  • 写回答

1条回答 默认 最新

  • dongping4461 2014-08-27 04:56
    关注

    It should be:

    define( "THEME_LOC", get_template_directory_uri() );

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 Macbookpro 连接热点正常上网,连接不了Wi-Fi。
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程