最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - wordpress can't find single-project page

programmeradmin0浏览0评论

I created a project form for adding projects,but when I create it,a wrong link create this is how I created project form:

 add_action('init' , 'create_project');
function create_project()
{
    $labels = array(
        'name' => _x('پروژه های جدید', 'post type general name'),
        'singular_name' => _x('پروژه', 'post type singular name'),
        'add_new' => _x('افزودن', 'پروژه'),
        'add_new_item' => __('افزودن پروژه'),
        'edit_item' => __('ویرایش پروژه'),
        'new_item' => __('جدید پروژه'),
        'view_item' => __('نمایش پروژه'),
        'search_items' => __('جستجوی پروژه'),
        'not_found' => __('پروژهی وجود ندارد'),
        'not_found_in_trash' => __('در زباله دان پروژهی نیست'),
        'parent_item_colon' => __('ویرایش پروژه'),
    );

    $support = array('title', 'excerpt', 'custom-fields', 'editor', 'thumbnail');

    register_post_type('project', array(
        'labels' => $labels,
        'supports' => $support,
        'public' => true
    ));
    }

single-project.php

<?php
get_header();?>

<?php if (have_posts()){ ?>
<section class="page-title parallax-section">
    <div class="row-parallax-bg">
        <div class="parallax-wrapper">
            <div class="parallax-bg">
                <img src="images/bg-image-54.jpg" alt="">
            </div>
        </div>
        <div class="parallax-overlay"></div>
    </div>
    <div class="centrize">
        <div class="v-center">
            <div class="container">
                <div class="single-post-info">
                    <h6><span><i class="hc-clock"></i>تاریخ پست</span><span class="post-time">22<?php the_date('D/M/Y') ?></span><span> در <a href="#"><?php the_category(); ?></a></span></h6>
                    <div class="title text-center">
                        <h1>لورم ایپسوم متن ساختگی با </h1>
                    </div>
                    <div class="post-author">
                        <img src="images/testimonial-2.jpg" alt=""><a href="#"><?php the_modified_author(); ?></a>
                    </div>
                </div>
                <?php the_meta(); ?>
            </div>
        </div>
    </div>
</section>
<?php } ?>

the link that creating is:'http://localhost/wordpress/faradars/project/project/' and it open 404page can anyone help me to fix it?

I created a project form for adding projects,but when I create it,a wrong link create this is how I created project form:

 add_action('init' , 'create_project');
function create_project()
{
    $labels = array(
        'name' => _x('پروژه های جدید', 'post type general name'),
        'singular_name' => _x('پروژه', 'post type singular name'),
        'add_new' => _x('افزودن', 'پروژه'),
        'add_new_item' => __('افزودن پروژه'),
        'edit_item' => __('ویرایش پروژه'),
        'new_item' => __('جدید پروژه'),
        'view_item' => __('نمایش پروژه'),
        'search_items' => __('جستجوی پروژه'),
        'not_found' => __('پروژهی وجود ندارد'),
        'not_found_in_trash' => __('در زباله دان پروژهی نیست'),
        'parent_item_colon' => __('ویرایش پروژه'),
    );

    $support = array('title', 'excerpt', 'custom-fields', 'editor', 'thumbnail');

    register_post_type('project', array(
        'labels' => $labels,
        'supports' => $support,
        'public' => true
    ));
    }

single-project.php

<?php
get_header();?>

<?php if (have_posts()){ ?>
<section class="page-title parallax-section">
    <div class="row-parallax-bg">
        <div class="parallax-wrapper">
            <div class="parallax-bg">
                <img src="images/bg-image-54.jpg" alt="">
            </div>
        </div>
        <div class="parallax-overlay"></div>
    </div>
    <div class="centrize">
        <div class="v-center">
            <div class="container">
                <div class="single-post-info">
                    <h6><span><i class="hc-clock"></i>تاریخ پست</span><span class="post-time">22<?php the_date('D/M/Y') ?></span><span> در <a href="#"><?php the_category(); ?></a></span></h6>
                    <div class="title text-center">
                        <h1>لورم ایپسوم متن ساختگی با </h1>
                    </div>
                    <div class="post-author">
                        <img src="images/testimonial-2.jpg" alt=""><a href="#"><?php the_modified_author(); ?></a>
                    </div>
                </div>
                <?php the_meta(); ?>
            </div>
        </div>
    </div>
</section>
<?php } ?>

the link that creating is:'http://localhost/wordpress/faradars/project/project/' and it open 404page can anyone help me to fix it?

Share Improve this question asked May 28, 2020 at 13:46 hadishadis 212 bronze badges 3
  • Have you made sure to flush your permalinks by going to Settings > Permalinks? – Jacob Peattie Commented May 28, 2020 at 13:54
  • actully no,what should I do? – hadis Commented May 28, 2020 at 14:12
  • Go to Settings > Permalinks. That’s it. – Jacob Peattie Commented May 28, 2020 at 14:50
Add a comment  | 

1 Answer 1

Reset to default 0

By analysis, your code maybe you should try

  • Flush permalinks (This may solve this issue) because when we create custom post type in WordPress we should use flush_rewrite_rules() or manually update permalinks.

Hope it will solve this issue.

发布评论

评论列表(0)

  1. 暂无评论