Шаблон single.php

189
19 апреля 2019, 02:40

У меня есть post type "news" я сделал для него шаблон single-news. Но когда перехожу по ссылки на конкретную новость мне выдает 404 страницу. Как решить эту проблему ?

Вот код single-news.php
      <?php
    /*
    Template Name: News item
    */
    ?>
    <?php get_header(); ?>
    <?php get_template_part('includes/promo/promo-small'); ?>
    <?php get_template_part('includes/breadcrumbs/breadcrumbs'); ?>
    <?php get_template_part('includes/news/news-item'); ?>
    <?php get_footer(); ?>

вот код news-item.php

      <section class="news">
      <div class="wrap">
         <article class="news__article">
          <h2 class="title news__article-title">Заглушка для конфирмата</h2>
          <figure class="news__img">
            <img src="/wp-content/themes/smwood/img/news/1.jpg" alt="">
          </figure>
          <time class="news__item-date" datetime="2018-08-25">25 июня 2018</time>
          <div class="news__item-descr">
            <h3>Familiarize yourself with those names</h3>
            <p>While house hunting, and also while going through the legal steps to rent a property in Dubai you are going to hear some very important names, here are those names and what they stand for. The Real Estate Regulatory Agency (RERA) is the Government department that monitors and regulates the ownership and rental of property in Dubai. Since this department was established it has provided much better conditions for tenants. So make sure the broker you are dealing with <a href="#">is registered.</a></p>
            <p>While house hunting, and also while going through the legal steps to rent a property in Dubai you are going to hear some very important names, here are those names and what they stand for. The Real Estate Regulatory Agency (RERA) is the Government department that monitors and regulates the ownership and rental of property in Dubai. Since this department was established it has provided much better conditions for tenants. So make sure the broker with is registered.</p>
          </div>
          <a href="#" class="news__link news__back">Назад</a>
        </article>
      </div>
    </section>

По сути должна вывести статическая страничка с моей разметкой. Но почему то идет 404. В .htaccess не каких редеректов нет.

Answer 1

После создания Custom Post Type необходимо зайти в постоянные ссылки и нажать кнопку "Сохранить изменения" после этого у вас всё заработает. Но так как вы переключили тему на другую и потом вернулись, все ваши ссылки автоматически пересохранились и у вас тоже все начало работать.

Поэтому информация на будущее, достаточно только нажать "Сохранить изменения" в разделе Настройки > Постоянные ссылки

READ ALSO
Почему входит в массив?

Почему входит в массив?

Почему выводит "входит"?

173
Поиск блока кода с последующей заменой в SQL

Поиск блока кода с последующей заменой в SQL

Всем приветНужно найти и поменять блок кода в БД

174
PHP не принимает ajax

PHP не принимает ajax

Всем здравствуйте) Что имею: Ссылка:

152