Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress get\u template\u directory()不返回任何内容_Wordpress_Wordpress Theming - Fatal编程技术网

Wordpress get\u template\u directory()不返回任何内容

Wordpress get\u template\u directory()不返回任何内容,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我第一次做一些自定义主题的工作,我想使用 <?php get_template_directory(); ?>/main.css 我可能删除了Wordpress用来导出此路径的任何设置或选项。Wordpress使用什么逻辑来确定模板目录是什么 作为测试,我添加了以下代码: DIRS: Plugins <?php plugins_url(); ?> <?php plugin_dir_url(); ?> <?php plugin_dir_path();

我第一次做一些自定义主题的工作,我想使用

<?php get_template_directory(); ?>/main.css 
我可能删除了Wordpress用来导出此路径的任何设置或选项。Wordpress使用什么逻辑来确定模板目录是什么

作为测试,我添加了以下代码:

DIRS:

Plugins
<?php plugins_url(); ?>
<?php plugin_dir_url(); ?>
<?php plugin_dir_path(); ?>
<?php plugin_basename(); ?>
Themes
<?php get_template_directory_uri(); ?>
<?php get_stylesheet_uri(); ?>
<?php get_theme_root_uri(); ?>
<?php get_theme_root(); ?>
<?php get_theme_roots(); ?>
Site Home
<?php home_url(); ?>
WordPress
<?php admin_url(); ?>
<?php site_url(); ?>
<?php content_url(); ?>
<?php includes_url(); ?>
<?php wp_upload_dir(); ?>
Multisite
<?php get_admin_url(); ?>
<?php get_home_url(); ?>
<?php get_site_url(); ?>
<?php network_admin_url(); ?>
<?php network_site_url(); ?>
<?php network_home_url(); ?>
所以很明显我搞错了Wordpress需要确定的目录。但是我在谷歌上找不到任何关于Wordpress如何生成这些路径的信息,而且源代码对我来说也不明显。

返回一个字符串。这是以
get\ucode>开头的WordPress函数的常见行为。尝试:

<?php echo get_template_directory(); ?>/main.css 
/main.css

根据您的计划,您还可以使用:

<?php bloginfo('template_url'); ?>

是的,这似乎是答案。我对PHP还不熟悉,我想我还是有点困惑,为什么它不回显字符串,但现在我知道我的问题是什么了,我应该能够解决它。
<?php echo get_template_directory(); ?>/main.css 
<?php bloginfo('template_url'); ?>