0
我已經創建了自定義帖子的自定義帖子類型,並在主題的index.php上顯示它們。當我使用wordpress分頁,並在第2頁上,沒有任何顯示在那裏,它發生在頁面找不到! 以下是代碼Wordpress分頁自定義帖子類型不工作
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/