Wordpress 404页未找到自定义文章类型的分页和永久链接错误

Wordpress 404页未找到自定义文章类型的分页和永久链接错误,wordpress,custom-post-type,permalinks,Wordpress,Custom Post Type,Permalinks,我在wordpress中创建了一个自定义帖子类型,方法是将以下内容添加到我的custom themes function.php中 function oil_paintings_init() { $args = array( 'labels' => array( 'name' => __( 'oil-paintings' ), 'singular_name' => __( 'oil-painting' ), 'rewrite' => array

我在wordpress中创建了一个自定义帖子类型,方法是将以下内容添加到我的custom themes function.php中

function oil_paintings_init() {
$args = array(
  'labels' => array(
    'name' => __( 'oil-paintings' ),
    'singular_name' => __( 'oil-painting' ),
    'rewrite' => array( 'slug' => 'oil-painting'),
  ),
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'query_var' => true,
    'menu_icon' => 'dashicons-format-image',
    'supports' => array(
        'title',
        'editor',
        'revisions',
        'page-attributes',)
    );
register_post_type( 'oil-paintings', $args );
}
add_action( 'init', 'oil_paintings_init' );
我已经创建了一个自定义页面模板,它循环并显示我上面添加的自定义帖子类型中的帖子。我想一次显示5篇文章,并在页面上的下一个和上一个链接休息。这是我使用的代码:

<?php
  $currentPage = (get_query_var('paged'))? get_query_var('paged') : 1;
  $args =array(
         'post_type'=>'oil-paintings',
          'posts_per_page' => 5,
         'nopaging' => false, 
          'paged' => $currentPage, 

    );
$wp_query = new WP_Query($args);
?>

<?php if($wp_query->have_posts()): while($wp_query->have_posts()) :    $wp_query->the_post(); ?>
    <div class="columns">
    <img src="<?php the_field('image1'); ?>" alt="" />
    <a href="<?php the_Permalink(); ?>"><?php the_title(); ?></a>
    </div>
<?php endwhile;
 next_posts_link("next");
 previous_posts_link("prev");
 endif; 
 wp_reset_postdata(); ?>
下一篇和上一篇文章链接停止工作,我得到一个页面未找到错误。如果我的永久链接设置为普通,一切正常

'http://www.domainname.com/?p=123' --> this works
感谢您在这方面给予的帮助。 谢谢

好吧,我知道我错在哪里了。将重写移出标签数组为我解决了这个问题。下面是functions.php中的工作代码

 function oil_paintings_init() {
$args = array(
  'labels' => array(
    'name' => __( 'oil-paintings' ),
    'singular_name' => __( 'oil-painting' )
  ),
   'rewrite' => array( 'slug' => 'oil-painting'),
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'query_var' => true,
    'menu_icon' => 'dashicons-format-image',
    'supports' => array(
        'title',
        'editor',
        'revisions',
        'page-attributes',)
    );
register_post_type( 'oil-paintings', $args );
}
add_action( 'init', 'oil_paintings_init' );

为什么permalink中有两个斜杠(
/
)?您能否提供一个404页面的示例(域后的路径)?我猜你使用的任何帖子名称都可能包含特殊字符,这会导致页面失败。您可能需要使用esc_url()这是我得到的。您是否更新了
.htaccess
文件?-你能确认一下吗?i、 e.您需要确保您有权修改文件是的,.hhtaces文件已更新
 function oil_paintings_init() {
$args = array(
  'labels' => array(
    'name' => __( 'oil-paintings' ),
    'singular_name' => __( 'oil-painting' )
  ),
   'rewrite' => array( 'slug' => 'oil-painting'),
    'public' => true,
    'show_ui' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'query_var' => true,
    'menu_icon' => 'dashicons-format-image',
    'supports' => array(
        'title',
        'editor',
        'revisions',
        'page-attributes',)
    );
register_post_type( 'oil-paintings', $args );
}
add_action( 'init', 'oil_paintings_init' );