Post page displaying sub page without URL change

I am working on a website on WordPress for a company and I am running into the following issue. This is the structure:

Section:

fruits

Categories (sub-sections):

red, yellow, blue, orange

Items (sub-sub-sections):

apples, oranges, lemons, blueberries

Fruits is based on the Posts section of the site (it has the little pushpin beside it). The category plays into the URL for that page, so when an item is selected it would look something like:

food.com/fruits/red/apples/

The category page has it's own page with some visual navigation and a blurb about that category. When the fruits are selected and you navigate to one of those categories however, the page shows the content of the fruit instead of the category page that was built itself.

For ex, the URL looks like:

food.com/fruits/red/

but it is showing the page

food.com/fruits/red/apples/

without changing the URL.

The only way I have remedied this so far is by NOT selecting a category, however then I run into the issue where the URL for that fruit page looks like this:

food.com/fruits/colour/apples/

I haven't been able to find any information on this subject so far, and any help would be greatly appreciated.

In the following image you can see that the next step displays the wrong page, however the permalink at the second page is the same in both cases.

visual of this problem

Edit:

archive-fruits.blade.php

@include('page')

page.blade.php

@php $iterator = 0 @endphp
@extends('layouts.app')

@section('content')
  @while(have_posts()) @php the_post() @endphp
    @if ($flexible_content)
      @foreach ($flexible_content as $block)
        @if ($block->block_type == 'markets_slider')
          @include('partials.markets-slider')
        @elseif ($block->block_type == 'static_content')
          @include('partials.static-content')
        @elseif ($block->block_type == 'expandable_content')
          @include('partials.expandable-content')
        @elseif ($block->block_type == 'image_+_text_listings')
          @include('partials.image-plus-text-listings')
        @elseif ($block->block_type == 'farmers_markets_list')
          @include('partials.farmers-markets-list')
        @elseif ($block->block_type == 'fruits_list')
          @include('partials.fruits-list')
        @elseif ($block->block_type == 'tabbed_content')
          @include('partials.tabbed-content')
        @endif
      @endforeach
    @endif

  @endwhile
@endsection

layouts: app.blade.php

<!doctype html>
<html {!! get_language_attributes() !!}>
  @include('partials.head')
  <body @php body_class() @endphp>
    @php do_action('get_header') @endphp
    @include('partials.header')
    <div class="wrap container" role="document">
      <div class="content">
        <main class="main">
          @yield('content')
        </main>
        @if (App\display_sidebar())
          <aside class="sidebar">
            @include('partials.sidebar')
          </aside>
        @endif
      </div>
    </div>
    @php do_action('get_footer') @endphp
    @include('partials.footer')
    @php wp_footer() @endphp
  </body>
</html>


Read more here: https://stackoverflow.com/questions/68381474/post-page-displaying-sub-page-without-url-change

Content Attribution

This content was originally published by Briana at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: