Template Page not working!

Hello, I am very new to this Sage Template.

I created a new template and it does not seem to display in the frontend correctly:

Please help me out, I am going crazy

What is it not displaying ??

If the content is not being displayed. You are missing the content tag.

  @while(have_posts()) 
     @php the_post() @endphp
     @php the_content() @endphp <<<< You may be missing this.
  @endwhile

Also the page you want this template to be used, you will have to select it from the right panel.

Which in your case would be “Restaurant Template”.

No it has nothing to do with that, in the image above that is what I am seeing in the frontend of the site. All the code from the template in the backend, is displaying in the front.

I have also selected the template page to be Restaurant Template. Everything is fine, just that my code is showing in frontend

You need to give more details for someone to suggest you.

What is the file name?
Where is it created?
How is it being called?

Do you see header footer on the same page?

I duplicated the file template-custom.blade.php to be template-restuarant.blade.php in the folder resources/views (where the rest of the template pages are sitting). Once I did that, I created a page in WordPress called Restaurant, which then I assigned my template “Restaurant Template” to that page. I then clicked up date.

And when I clicked to see if the page is displaying correctly (example: header or footer, etc).

I see only the code that was placed in the template-restaurant.blade.php. No header, no footer, etc. Just the template code

Here is the image below:

and here is the code:

{{--
  Template Name: Restaurant Template
--}}

@extends('layouts.app')

@section('content')
   @while(have_posts()) 
     @php the_post() @endphp
     @php the_content() @endphp
@endwhile
@endsection

I don’t know if this would exactly be the cause of this but, have set your resources/assets/config.json correctly.

  "publicPath": "/public-path/to-theme/without-slash",
  "devUrl": "http://example.test", << Your real site.

Are other templates working? For Example. 404, search ??

I will try out the above, but yes, all the other pages are working 100%

UPDATE: I did as you mentioned above, however I also have this code below that:

"proxyUrl": "http://localhost:3000",
	"cacheBusting": "[name]_[hash:8]",
	"watch": [
		"app/**/*.php",
		"config/**/*.php",
		"resources/views/**/*.php"

Not sure if that makes a difference, but I still get the same issue

You can share your project, and I will look at it when I get free. I can’t commit the time.

Do you get the same result when you assign the original template-custom.blade.php to a page? The issue you’re seeing is that Blade isn’t parsing that file for some reason–i.e. it’s just being included instead of interpreted. If your other pages work fine, then there’s something unique happening with that page. Is this a brand new theme? Do you have any plugins, custom post types, filters, etc set up?

Turns out I had it template-name-blade.php not template-name.blade.php

Such a noob, seems like a stupid mistake on my end.

1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.