我已經包括wordpress進入magento爲了使用WordPress的功能,通過添加以下行到magentos index.php
。WordPress的注入代碼到頁眉和頁腳在Magento WordPress的整合
define('WP_USE_THEMES', false);
require_once MAGENTO_ROOT . '/blog/wp-load.php';
但這種莫名其妙的代碼注入WordPress的wp_head
和頭wp_footer
代碼和Magento的文件頁腳。
這是我的magento模板文件(2columns-left.phtml
)。
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
</body>
</html>
但輸出
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
img.wp-smiley,
img.emoji {
display: inline !important;
border: none !important;
box-shadow: none !important;
height: 1em !important;
width: 1em !important;
margin: 0 .07em !important;
vertical-align: -0.1em !important;
background: none !important;
padding: 0 !important;
}
</style>
<style type="text/css">
.mobile-menu {
position: -webkit-sticky;
position: -moz-sticky;
position: -ms-sticky;
position: -o-sticky;
position: sticky;
}
</style>
</head>
<body>
<script type='text/javascript' src='https://SITNAME.com/blog/wp-includes/js/jquery/jquery.js?ver=1.12.4'></script>
<script type='text/javascript' src='https://SITNAME.com/blog/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1'></script>
</body>
</html>
無法理解怎麼能WP注入HTML到頁眉和頁腳,而不調用任何PHP函數(注風格和腳本標記)。我甚至也禁用了JS。任何幫助高度讚賞。
編輯: 這不是特有的magento。我將wp-load.php
包含到獨立的php腳本和wordpress更改輸出中。在標題和正文結束之前添加樣式和腳本。
謝謝你..作品,但如果我鉤入WP行動不起作用。如果我使用它沒有任何行動,那麼它的作品。試圖找出一個適當的鉤子。你也有一個想法,我應該在哪裏包含這段代碼?怎麼樣magento的index.php? – mysterious
@mysterious嘗試'init'鉤子。這是一個WordPress的安裝,所以,正如我上面提到的functions.php文件將罰款(兒童主題或不)。如果它沒有掛鉤,就不要使用它。很高興我能幫上忙。 – vagelis
我會嘗試初始化。我沒有把它放在functions.php中,因爲我將WP_USE_THEMES設置爲false。感謝您讓我走上正軌。賞金頒發。 – mysterious