首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在WordPress中找不到自定义帖子类型单页

问在WordPress中找不到自定义帖子类型单页
EN

Stack Overflow用户
提问于 2020-11-28 15:53:00
回答 1查看 35关注 0票数 0

这是我在function.php文件中的自定义post类型代码:

代码语言:javascript
复制
function muslim_taha_khedamate()
{

    register_taxonomy_for_object_type('category', 'muslim'); // Register Taxonomies for Category
    register_taxonomy_for_object_type('post_tag', 'muslim');
    register_post_type('services', // Register Custom Post Type
        array(
        'labels' => array(
            'name' => __('خدمات', 'muslim'), // Rename these to suit
            'singular_name' => __('خدمت', 'muslim'),
            'add_new' => __('اضافه کردن', 'muslim'),
            'add_new_item' => __('خدمت جدید اضافه کنید.', 'muslim'),
            'edit' => __('ویرایش', 'muslim'),
            'edit_item' => __('ویرایش خدمت', 'muslim'),
            'new_item' => __(' جدید', 'muslim'),
            'view' => __('نمایش خدمت', 'muslim'),
            'view_item' => __('نمایش خدمت', 'muslim'),
            'search_items' => __('جستجوی خدمت', 'muslim'),
            'not_found' => __('خدمتی پیدا نشد.', 'muslim'),
            'not_found_in_trash' => __('خدمتی در زباله دان پیدا نشد.', 'muslim')
        ),
        'public' => true,
        'hierarchical' => true, // Allows your posts to behave like Hierarchy Pages
        'has_archive' => true,
        'menu_icon' => 'dashicons-admin-multisite',
        'supports' => array(
            'title',
            'editor',
            'excerpt',
            'thumbnail'
        ), // Go to Dashboard Custom HTML5 Blank post for supports
        'can_export' => true, // Allows export in Tools > Export
        'taxonomies' => array(
            'post_tag',
            'category'
        ) // Add Category and Post Tags support
    ));
}

add_action('init', 'muslim_taha_khedamate'); // Add services Custom Post Type

我的问题是:

代码语言:javascript
复制
<div class="row">
        <?php 
   $args = array(
        'post_type'=>'services',
        'posts_per_page'=>3,
        'orderby'=>'date',
        'order'=>'ASC'
   );
 $service = new WP_Query($args);
 ?>
        <?php
    while($service->have_posts()): $service->the_post(); ?>
        <div class="service col-md-4 col-sm-4">
            <a href="<?php the_permalink(); ?>">
                <div class="service-item card text-center mb-4">
                    <div class="image card-header text-center m-auto ">
                        <?php  the_post_thumbnail( 'service',array('class'=>'img-fluid')) ?>
                    </div>
                    <div class="card-body pt-5">
                        <h3> <?php the_title(); ?></h3>
                    </div>
                </div>
            </a>
        </div>
        <?php endwhile; wp_reset_postdata();?>
    </div>

我有一个单页面single-services.php,它必须显示每个帖子的单个页面,但不幸的是,当我单击每个自定义帖子类型时,它会给我错误404。我有三个相同的结构自定义帖子类型,其中两个是正确的,但这个不是。

有谁能帮帮我吗?谢谢..。

EN

回答 1

Stack Overflow用户

发布于 2020-11-28 16:52:24

在自定义帖子类型的单页上试用

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" > </a>

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65047556

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档