如何在将HTML模板转换为wordpress主题时链接style.css文件

我有一个HTML模板, 我想将其转换为Wordpress主题。 WordPress主题需要style.css和index.php才能工作, 但是模板没有csse文件, 而是具有css文件夹。如何连结?


#1


你可以使用get_template_directory_uri()函数。

例如:

<link rel =” stylesheet” href =” <?php echo get_template_directory_uri();?> / css / style.css” />


#2


将其放在标题中可以正常工作。这是在Wordpress上执行此操作的”正确”方法-你的functions.php文件或自定义插件中包含以下内容。

function thatwomanuk_header_scripts()
{
    // My stylesheet
    wp_register_style('mystyles', get_template_directory_uri().'/css/style.css', array(), '1.0', 'all');
    wp_enqueue_style('mystyles');
}

add_action('init', 'thatwomanuk_header_scripts'); // Add Custom Scripts to wp_head

样式表和javascript的参数是:名称/句柄, 源, 类型, 数组(依赖项), 版本, 延迟。最后的”全部”是此样式表的媒体查询-例如, 它可以是”屏幕”或”打印”。

此处以及其他地方的更多信息:http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/

来源:

https://www.srcmini02.com/65391.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_37287.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?