【发布时间】:2021-09-23 15:12:05
【问题描述】:
我正在为一家公司开发一个关于 WordPress 的网站,我遇到了以下问题。这是结构:
部分:
fruits
类别(子部分):
red, yellow, blue, orange
项目(子小节):
apples, oranges, lemons, blueberries
Fruits 基于站点的Posts 部分(旁边有一个小图钉)。 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/
类别页面有它自己的页面,带有一些视觉导航和关于该类别的简介。选择果实并导航到其中一个类别时,页面显示水果的内容而不是构建自身的类别页面。
例如,网址如下所示:
food.com/fruits/red/
但它正在显示页面
food.com/fruits/red/apples/
不更改 URL。
到目前为止,我解决此问题的唯一方法是不选择类别,但是随后我遇到了该水果页面的 URL 如下所示的问题:
food.com/fruits/colour/apples/
到目前为止,我还没有找到有关此主题的任何信息,我们将不胜感激。
在下图中,您可以看到下一步显示错误的页面,但是在两种情况下,第二页的永久链接是相同的。
编辑:
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
布局: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>
【问题讨论】:
标签: wordpress url wordpress-theming custom-wordpress-pages slug