Logo
X
  • Who We Serve
    • By Role

      • CEO / Business Executives
      • CTO / IT Professionals
      • COO / Operations Head
    • By Industries

      • Healthcare
      • Digital Commerce
      • Travel and Transportation
      • Real Estate
      • Software and Technology
  • Our Technology Focus
    • Web
    • Mobile
    • Enterprise
    • Artificial Intelligence
    • Blockchain
    • DevOps
    • Internet Of Things
  • Discover Daffodil
    • About
    • Leadership
    • Corporate Social
      Responsibility
    • Partners
    • Careers
  • Resources
    • Blog

    • E-Books

    • Case Studies

    • View all resources

  • Who We Serve
    • By Role

      • CEO / Business Executives
      • CTO / IT Professionals
      • COO / Operations Head
    • By Industries

      • Healthcare
      • Digital Commerce
      • Travel and Transportation
      • Real Estate
      • Software and Technology
  • Our Technology Focus
    • Web

      Create responsive web apps that excel across all platforms

    • Mobile

      User centric mobile app development services that help you scale.

    • Enterprise

      Innovation-driven enterprise services to help you achieve more efficiency and cost savings

      • Domains
      • Artificial Intelligence
      • DevOps
      • Blockchain
      • Internet Of Things
  • Discover Daffodil
    • About
    • Leadership
    • Corporate Social Responsibilities
    • Partners
    • Careers
  • Resources
    • Blog

      Insights for building and maintaining your software projects

    • E-Books

      Our publications for the connected software ecosystem

    • Case Studies

      The impact that we have created for our clients

    • View all resources
daffodil-logo
Get in Touch
  • What We Do
    • Product Engineering

    • Discover & Frame Workshop
    • Software Development
    • Software Testing
    • Managed Cloud Services
    • Support & Maintenance
    • Smart Teams

    • Dedicated Teams
    • Offshore Development Centre
    • Enterprise Services

    • Technology Consulting
    • Robotic Process Automation
    • Legacy Modernization
    • Enterprise Mobility
    • ECM Solutions
  • Who We Serve
    • By Industry

    • Healthcare
    • Software & Technology
    • Finance
    • Banking
    • Real Estate
    • Travel & Transportation
    • Public Sector
    • Media & Entertainment
    • By Role

    • CEO / Business executives
    • CTO / IT professionals
    • COO / Operations
  • Our Expertise
    • Mobility
    • UI/UX Design
    • Blockchain
    • DevOps
    • Artificial Intelligence
    • Data Enrichment
    • Digital Transformation
    • Internet of Things
    • Digital Commerce
    • OTT Platforms
    • eLearning Solutions
    • Salesforce
    • Business Intelligence
    • Managed IT Services
    • AWS Services
    • Application Security
    • Digital Marketing
  • Case Studies
  • Discover Daffodil
    • About us
    • Partnership
    • Career & Culture
    • Case Studies
    • Leadership
    • Resources
    • Insights Blog
    • Corporate Social Responsibility
Get in Touch
resources-bg.jpg

Software Engineering Insights

Integrating Magento Header/Footer in Wordpress - Solved

May 13, 2015 5:01:37 PM

  • Tweet

Blogs are of paramount importance to a website and especially to a Magento Developed Online Store. Blogs bring forth traffic and are the prime source of SEO leads. In this tight race of Blogging Platforms, Wordpress has turned out to be the fastest horse in the derby.

Wordpress is the best platform to showcase Blogs and Case Studies. Now if you wish to combine the superiority of Wordpress with a Magento Store then this article is the perfect solution to your problems.

Integrating Magento Header Footer in Wordpress - Solved

Here we will talk in details how to integrate your Magento Header & Footer in a Wordpress site.
We are considering Wordpress code is within a folder named "blog" inside the Magento project.

[php]$str = dirname(__FILE__);

$basedir = substr($str, 0, strpos($str, 'blog'));
$mage_php_url = $basedir . 'app/Mage.php';

// Include Magento application

if (!empty($mage_php_url) && file_exists($mage_php_url) && !is_dir($mage_php_url)) {
// Include Magento's Mage.php file
require_once ( $mage_php_url );
umask(0);
Mage::app();
[/php]

After this you can use the Magento code in your WordPress code.

[php]$url = Mage::getBaseUrl();
$url = substr($url, 0, strpos($url, 'index.php'));
// skin url of magento
$skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
//js url
$jsUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);[/php]

This will provide you with the Magento url, Skin url and js url.

Include Magento session so that customer and checkout session will be maintained in it.

[php]Mage::getSingleton('core/session', array('name'=>'frontend'));[/php]

After inserting this line if the user is logged into Magento then it will show him/her as logged into Wordpress as well. Cart header will show updated cart items as well.

Now let’s include time the js and css files. Include all js and css files of Magento to get the style and functionality of Magento.

[php]<link rel="stylesheet" type="text/css" href="<?php echo $skinUrl . 'frontend/default/default/css/styles.css'?>" media="all" />
<script type="text/javascript" src="<?php echo $jsUrl .'prototype/prototype.js'?>"></script>[/php]

In similar ways, you can include other files as well.

The Header

[php]$_layout = Mage::getSingleton('core/layout');
$block_header = $_layout->createBlock('page/html_header')-
>setTemplate('page/html/header.phtml');[/php]

This will include header.phtm files.

Top Menu

[php]$block_Menu = $_layout->createBlock('page/html_topmenu', 'catalog.topnav')-
>setTemplate('page/html/topmenu.phtml');
$block_header->setChild('topMenu', $block_Menu);[/php]

Likewise include the other needed block

Top Links

[php]$block_links = $_layout->createBlock('page/template_links', 'top.links')->setTemplate('page/template/links.phtml');
$block_header->setChild('topLinks', $block_links);
$block_links->addLink('Home', $url . '', 'Home','', '', 10,'', 'class="top-link-home"');
$block_links->addLink('Account', $url . 'customer/account/', 'Account', '', '', 10,'','class="top-link-account"');
$block_links->addLink('Shopping Cart', $url . 'checkout/cart/', 'Shopping Cart', '', '', 10,'','class="top-link-cart"');
$block_links->addLink('Checkout', $url . 'checkout/onepage/', 'Checkout', '', '', 10,'','class="top-link-checkout"');[/php]

New Call-to-action      
It will include Home, Account, Cart and Checkout link on the header. Other links can be added similarly.

[php]echo $block_header->toHtml();[/php]

This will show the header html.

Footer

[php] $layout = Mage::getSingleton('core/layout');
$footerBlock = $layout->createBlock('page/html_footer')->setTemplate('page/html/footer.phtml');
$news_subscribe = $layout->createBlock('newsletter/subscribe')->setTemplate('newsletter/subscribe.phtml');
$footerBlock->setChild('newsletter', $news_subscribe);
echo $footerBlock->toHtml();[/php]

This will include footer.phtml file and it will be called ‘Newsletter’ inside the footer.

I can say with a good amount of certainty that this article will help you in including Magento styles in your Wordpress site.

Happy Coding

Topics: Digital Commerce Open Source

Ankita Agrawal

Written by Ankita Agrawal

Ankita Agrawal is leading Magento team and providing best in class e-commerce products and aimed at client satisfaction. She is very good at innovating and implementing latest marketplace solutions. Having a great experience of providing customized and featured products, she fits best for handling higher complexity projects.

Previous Post

previous_post_featured_image

"YOU" at the heart of Goal Setting

Next Post

next_post_featured_image

Drupal 8 Responsive Design: The 'Mobilegeddon' Survival Kit

Stay Ahead of the Curve with Our Weekly Tech Insights

  • Recent
  • Popular
  • Categories

Lists by Topic

  • Software Development (174)
  • Artificial Intelligence (169)
  • Mobile App Development (166)
  • Healthcare (137)
  • DevOps (80)
  • Digital Commerce (60)
  • Web Development (57)
  • CloudOps (54)
  • Digital Transformation (37)
  • Fintech (36)
  • UI/UX (29)
  • On - Demand Apps (26)
  • Software Architecture (26)
  • Internet of Things (IoT) (25)
  • Open Source (25)
  • Outsourcing (24)
  • Blockchain (21)
  • Newsroom (21)
  • Salesforce (21)
  • Technology (18)
  • Software Testing (16)
  • StartUps (16)
  • Customer Experience (14)
  • Robotic Process Automation (13)
  • Voice User Interface (13)
  • Javascript (11)
  • OTT Apps (11)
  • Business Intelligence (10)
  • Data Enrichment (10)
  • Infographic (10)
  • Big Data (9)
  • Education (9)
  • Microsoft (6)
  • Real Estate (5)
  • Banking (4)
  • Game Development (4)
  • Enterprise Mobility (3)
  • Hospitality (3)
  • eLearning (2)
  • Public Sector (1)
see all

Posts by Topic

  • Software Development (174)
  • Artificial Intelligence (169)
  • Mobile App Development (166)
  • Healthcare (137)
  • DevOps (80)
  • Digital Commerce (60)
  • Web Development (57)
  • CloudOps (54)
  • Digital Transformation (37)
  • Fintech (36)
  • UI/UX (29)
  • On - Demand Apps (26)
  • Software Architecture (26)
  • Internet of Things (IoT) (25)
  • Open Source (25)
  • Outsourcing (24)
  • Blockchain (21)
  • Newsroom (21)
  • Salesforce (21)
  • Technology (18)
  • Software Testing (16)
  • StartUps (16)
  • Customer Experience (14)
  • Robotic Process Automation (13)
  • Voice User Interface (13)
  • Javascript (11)
  • OTT Apps (11)
  • Business Intelligence (10)
  • Data Enrichment (10)
  • Infographic (10)
  • Big Data (9)
  • Education (9)
  • Microsoft (6)
  • Real Estate (5)
  • Banking (4)
  • Game Development (4)
  • Enterprise Mobility (3)
  • Hospitality (3)
  • eLearning (2)
  • Public Sector (1)
see all topics

Elevate Your Software Project, Let's Talk Now

Awards & Accolades

dj
dj
dj
dj
dj
Aws-certification-logo
microsoft-partner-2-1
microsoft-partner
google-cloud-partne
e-UI-Path-Partner-logo
partner-salesforce-reg-consulting-partner-1-1
daffodil-logo
info@daffodilsw.com
  • Home
  • About Daffodil
  • Locations
  • Privacy Policy
  • Careers

© 2025 Daffodil Unthinkable Software Corp. All Rights Reserved.

[fa icon="chevron-up"]