Roots Discourse

Can't access query variable when extending a partial template

Hi, I played with sage today and the result is pretty amazing. I really enjoy the theming experience of Sage. However, I have a minor issue that I can’t figure out by my self. I have a normal loop template and a template for related posts as follows.

|-- content.balde.php
|-- content-related.blade.php

Because only the thumbnail of the content-related template is different from the content so I extended content-related from content. But the thumbnail of all posts are the same and use the first related post in the loop. How can I debug/fix this?

{{-- content.blade.php --}}

<article @php post_class() @endphp>
  <a class="entry-thumbnail" href="{{ get_permalink() }}" title="{{ get_the_title() }}">
    @yield('thumbnail', get_the_post_thumbnail(null, 'thumbnail'))
  <header class="entry-header">
      @dump(get_the_ID) // Return the correct ID for each posts.
      <h2 class="entry-title"><a href="{{ get_permalink() }}">{!! get_the_title() !!}</a></h2>
{{-- content-related.blade.php --}}


  @dump(get_the_ID) // Return the same value for every posts.
  {!! the_post_thumbnail('related-thumbnail') !!}

Edit: The default yield section should be

      {!! get_the_post_thumbnail(null, 'thumbnail') !!}

Hi @dinhtungdu

In your partials files you have wrong name for blade.php

|-- content.balde.php
|-- content-related.blade.php

Thank for correcting me, it’s mistyped in the thread. I have the correct files on my hard drive :slight_smile: