我已经使用自定义分类创建了自定义帖子类型,并将它们显示在主题的 index.php 上。当我使用 wordpress 分页时,它在第 2 页上,没有任何显示在那里,它在页面未找到!以下是代码
add_action( 'init', 'register_success_stories' );
function register_success_stories(){
register_post_type( 'sajid-photos', array(
'label' => 'My Photos',
'singular_label' => 'My Photo',
'description' => 'Manage phots.',
'public' => TRUE,
'publicly_queryable' => TRUE,
'show_ui' => TRUE,
'query_var' => TRUE,
'rewrite' => TRUE,
'capability_type' => 'post',
'hierarchical' => FALSE,
'menu_position' => NULL,
'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields', 'revisions'),
'menu_position' => 5,
'rewrite' => array(
'slug' => 'sajid-photo-work',
'with_front' => FALSE,
),
'labels' => array(
'name' => __( 'My Photos' ),
'singular_name' => __( 'My Photos' ),
'add_new' => __( 'Add New Photo' ),
'add_new_item' => __( 'Add New Photo' ),
'edit' => __( 'Edit Photo' ),
'edit_item' => __( 'Edit Photo' ),
'new_item' => __( 'New Photo' ),
'view' => __( 'View Photo' ),
'view_item' => __( 'View Photo' ),
'search_items' => __( 'Search Photos' ),
'not_found' => __( 'No Photo Found' ),
'not_found_in_trash' => __( 'No Photo found in Trash' ),
'parent' => __( 'Parent Photo' ),
)
));
flush_rewrite_rules( false );
}
register_taxonomy('sajid-album', 'sajid-photos', array(
'label' => 'Albums',
'singular_label' => 'Album',
'public' => TRUE,
'show_tagcloud' => FALSE,
'hierarchical' => TRUE,
'query_var' => TRUE,
'rewrite' => array('slug' => 'sajid-album' )
));
以下是在主页上显示特定 texanomy 帖子的代码。
<?php
wp_reset_query();
global $post;
query_posts( array( 'post_type' => 'sajid-photos', 'sajid-album' => 'home-page-photos','paged' => $paged, 'posts_per_page' => 1 , 'paged' => get_query_var('paged')) );
if ( have_posts() ){
while ( have_posts() ) : the_post();
unset($thumb_big);
$thumb_big = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
$thumb_big_url = $thumb_big['0'];
?>
<a href="<?php echo $thumb_big_url; ?>" title="<?php the_title(); ?>" data-gal="prettyPhoto[1]" class="gallery-image"><img src="<?php echo $cfs->get('upload_thumbnail'); ?>" alt="<?php the_title(); ?>"></a>
<?php
endwhile;
} // end of if ( have_posts() )
theme_paginate();
wp_reset_query();
?>
此外,它的条款网址也不起作用,当我点击条款时,它会进入未找到的页面。请帮我解决这个问题。非常感谢您。网站网址是http://sajidz.w3made.com/