2013-09-16 79 views
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/

回答

0

对于初学者,理想情况下,你不会在WordPress的网站分页您的主页。但per the documentation如果您想要在静态首页上获取当前页面,则需要查找get_query_var('page')变量而不是“分页”。您正在使用theme_paginate();它出现分页链接,我不知道它是如何建立链接,所以这可能是你开始的第一个地方。

相关问题