我在函数中使用此代码。php:
add_action(\'wp_head\', \'addMyStyle\');
function addMyStyle() {
wp_enqueue_style( \'bootstrap\', get_template_directory_uri() . \'/css/bootstrap.css\', false, \'1.0\', \'all\', false );
wp_enqueue_style( \'bootstrap-rtl\', get_template_directory_uri() . \'/css/bootstrap-rtl.css\', false, \'1.0\', \'all\', false );
wp_enqueue_style( \'style\', get_template_directory_uri() . \'/style.css\', false, \'1.0\', \'all\' );
}
以及
<?php wp_head(); ?>
标签就在前面
</head>
标签但样式文件加载在页脚标记中。我想把这些样式载入头标签。
在我的内部<head>
标签:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="rtl" xml:lang="fa" lang="fa">
<?php global $current_user; get_currentuserinfo(); ?>
<head>
<meta name="theme-color" content="#1B5064" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="HandheldFriendly" content="True">
<link rel="shortcut icon" href="/favicon-16x16.png" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA--1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag(\'js\', new Date());
gtag(\'config\', \'UA--1\');
function resizeIframe(obj) {
obj.style.height = obj.contentWindow.document.body.scrollHeight + \'px\';
obj.style.height = 0;
obj.style.height = obj.contentWindow.document.body.scrollHeight + \'px\';
}
</script>
<meta name="google-site-verification" content="" />
<?php
if ( wp_is_mobile() ) {
?>
<style>.woocommerce-cart-form .container {overflow:scroll;}</style>
<?php
}
?>
<?php wp_head(); ?>
</head>