We noticed you're using an ad blocker

Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by disabling your ad blocker.

Laravel blade template in WordPress theme

world cup 2022


Get update standing EPL, UEFA, LaLiga and more

Get Now

There is several php template engine but Blade template engine is the most popular and simplistic way to write php code along with HTML. The popular Laravel Framework use it out of the box. If you are laravel developer then you already know how cool the Blade syntax. If you are not a Laravel developer you are also be impressed with Blade syntax after see the few examples.

In the WordPress template, where we need to write php code along with HTML then you know as a WordPress developer how the scenario is. Let's take a look a simple example but when it will be a big code it will be more complex. After showing some code example I'll show you how to integrate the blade template engine to your WordPress theme just 3 simple steps.


In normal PHP with HTML

<?php for($i;$i<5;$i++) { 
	if($i==2){ ?>
		<p> Name: <?php echo $name; ?>
	<?php } else { ?>
  	<p>Value: <?php $i; ?></p>
  	<?php } ?>
<? } ?>

In Blade syntax, you can do it with simple clean syntax and elegant way.

     <p> Name: {{$name}} </p>
     <p> Value: {{$i}} </p>

Let's see more examples.

foreach loop

@foreach($data as $row)
     Name: {{$row->name}} <br>
     Age: {{$row->age}} <br>

 if-else Conditional statement

   <p> Smith </p>
   <p> Adam </p>

include file 


wpquery WordPress loop

@wpquery(array('post_type' => 'post'))
  <p> No post found </p>

To know more about Blade template documentation


Now let's see the installation process with WordPress theme

Step 01: Download Blade template

Step 02: Extract the downloaded folder and copy the blade folder then paste the folder into your WordPress theme.

Step 03: Now open the functions.php file and simply include the line include("blade/blade.php")

Finished! Now you can use blade syntax in your WordPress theme.

Share on

Related Post - Latest Post

Tinkerpad - A minimal Laravel code editor

What's new in Laravel 9

Make laravel site super fast by page-cache!

Laravel maintenance mode bypass by Secret Route!

Laravel database backup automatically - cPanel shared hosting, VPS

Laravel Datatables - Ajax, Column, Buttons, Customization