skip to Main Content

I have included wordpress into magento in order to use wordpress functions by adding following lines to magentos index.php.

define('WP_USE_THEMES', false);
require_once MAGENTO_ROOT . '/blog/wp-load.php';

But this code somehow injects wordpress wp_head and wp_footer code in header and footer of magento files.

This is my magento template file (2columns-left.phtml).

<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>

</body>
</html>

but output is

<!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>

Cant understand how can wp inject html into header and footer without calling any php function (Note style and script tags). Even I disabled JS too. Any help highly appreciated.

Edit:
This is not magento specific. I include wp-load.php into an independent php script and wordpress changes output. Adds style and script in header and before body ends.

2

Answers


  1. I think you want WordPress integration with Magento then you need to use fishpig extension follow this URL
    https://fishpig.co.uk/magento/wordpress-integration/

    Login or Signup to reply.
  2. @mysterious could you try this in your functions.php and get back to us?

    function unhook_wp_head_footer(){
      global $wp_filter,$wpdb,$wp_query;
    
      if(is_page('2columns-left.phtml')) {
        foreach ( $wp_filter['wp_head'] as $priority => $wp_head_hooks ) {
          if( is_array( $wp_head_hooks ) ) {
            foreach ( $wp_head_hooks as $wp_head_hook ) {
              remove_action( 'wp_head', $wp_head_hook['function'], $priority );
            }
          }
        }
    
        foreach ($wp_filter['wp_footer'] as $priority => $wp_footer_hooks ) {
          if( is_array( $wp_footer_hooks ) ){
            foreach ( $wp_footer_hooks as $wp_footer_hook ) {
              remove_action( 'wp_footer', $wp_footer_hook['function'], $priority );
            }
          }
        }
      }
    }
    
    add_action( 'wp', 'unhook_wp_head_footer' );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search