Reputation: 3596
the following is the index.blade.php of laravel app.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-GB" xmlns="http://www.w3.org/1999/xhtml">
<?php
global $wp_rewrite;
define('WP_USE_THEMES', true);
// require_once (app_path().'/libraries/wp-config.php');
// require (app_path().'/libraries/wp-load.php');
require (app_path().'/libraries/wp-blog-header.php');
// require ('../app/libraries/wp-blog-header.php');
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<title> @yield('title') </title>
</head>
<body @yield('bodyclass')>
<div id="container">
<div id="primary-menu" class="dropdown-menu-wrap">
<?php wp_nav_menu(array('theme_location' => 'primary',
'container' => false,
'menu_class' => 'menu',
'menu_id' => '',
'fallback_cb' => false
)); ?>
</div>
trying to call the menu of the existing wordpress application. while the config.php is directly download from the existing wordpress, wp_include is fresh download from new wordpress files. same to wp-blog-header, wp-load, and wp-setting.
I not sure why keep on pop out the error of Call to a member function main() on a non-object. Tested all the available solution but failed.
function wp( $query_vars = '' ) {
global $wp, $wp_query, $wp_the_query;
$wp->main( $query_vars );
if ( !isset($wp_the_query) )
Upvotes: 0
Views: 1135
Reputation: 350
Instead of using WordPress Functions in "blade", you can pass it to variable and can call that into blade.
<?php
//In controller
$args = array(
array('theme_location' => 'primary',
'container' => false,
'menu_class' => 'menu',
'menu_id' => '',
'fallback_cb' => false,
'echo' => false
));
$data['menu'] = wp_nav_menu($args);
?>
//In blade
{{$menu}}
For Detailed, You can go through: Wordpress+Laravel
Upvotes: 0
Reputation: 21
I'm trying to do that as well and I think this could be an answer: https://github.com/swt83/laravel-wordpress/blob/master/readme.md
Best regards!;-)
Upvotes: 2