2012-12-11 68 views
2

我和我的朋友都对这里正在发生的事情完全被诅咒。任务是将标准分页从一篇文章链接到下一篇文章。我们可以看到从第2页/第3页/第3页开始的页面,但内容不会改变。WordPress自定义文章类型分页问题

这是我们在自定义模板中得到的。

<?php 
/** 
* The Template for displaying all single posts. 
* 
* Template Name: Portfolio 
* 
* @package WordPress 
* @subpackage Boilerplate 
* @since Boilerplate 1.0 
*/ 

get_header(); 

// Enable Pagination 
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1; 

$args = array(
'post_type' => array(
'portfolio' 
), 
'orderby' => 'date', 
'posts_per_page' => 1, 
'paged'=>$paged 
); 

$the_query = new WP_Query($args); 

while ($the_query->have_posts()) : $the_query->the_post(); 

?> 

<article id="item<?php the_ID(); ?>" <?php post_class('post portfolio'); ?>> 
    <h2><?php the_title(); ?></h2> 
    <div> 
    <?php the_content(); ?> 
    </div> 
</article> 

<?php endwhile; ?> 
    <?php next_posts_link('« Older Entries') ?> 
    <?php previous_posts_link('Newer Entries »') ?> 
<?php wp_reset_postdata(); ?> 

<?php get_footer(); ?> 

而在functions.php的底部生活中的一些自定义后类型的脚本...

// Custom Post Type 

function foggin_Portfolio() { 
$labels = array(
    'name'    => _x('Portfolio', 'post type general name'), 
    'singular_name'  => _x('Portfolio', 'post type singular name'), 
    'add_new'   => _x('Add New', 'book'), 
    'add_new_item'  => __('Add New Item'), 
    'edit_item'   => __('Edit item'), 
    'new_item'   => __('New Item'), 
    'all_items'   => __('All Items'), 
    'view_item'   => __('View Item'), 
    'search_items'  => __('Search items'), 
    'not_found'   => __('No item'), 
    'not_found_in_trash' => __('No items found in the Trash'), 
    'parent_item_colon' => '', 
    'menu_name'   => 'Portfolio' 
); 
$args = array(
    'labels'  => $labels, 
    'description' => 'Holds portfolio items and portfolio specific data', 
    'public'  => true, 
    'menu_position' => 5, 
    'rewrite'  => array('slug'=>'','with_front'=>false), 
    'supports'  => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'taxonomies'), 
    'taxonomies' => array('post_tag'), 
    'has_archive' => true, 
); 
register_post_type('portfolio', $args); 
} 

add_action('init', 'foggin_Portfolio'); 

function portfolio_messages($messages) { 
    global $post, $post_ID; 
    $messages['portfolio'] = array(
     0 => '', 
     1 => sprintf(__('Portfolio item updated. <a href="%s">View item</a>'), esc_url(get_permalink($post_ID))), 
     2 => __('Custom field updated.'), 
     3 => __('Custom field deleted.'), 
     4 => __('Product updated.'), 
     5 => isset($_GET['revision']) ? sprintf(__('Portfolio item restored to revision from %s'), wp_post_revision_title((int) $_GET['revision'], false)) : false, 
     6 => sprintf(__('Portfolio item published. <a href="%s">View item</a>'), esc_url(get_permalink($post_ID))), 
     7 => __('Portfolio item saved.'), 
     8 => sprintf(__('Portfolio item submitted. <a target="_blank" href="%s">Preview item</a>'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 
     9 => sprintf(__('Portfolio item scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview item</a>'), date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 
     10 => sprintf(__('Portfolio item draft updated. <a target="_blank" href="%s">Preview item</a>'), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 
     ); 
     return $messages; 
    } 

    add_filter('post_updated_messages', 'portfolio_messages'); 


    function portfolio_taxonomies() { 
     $labels = array(
     'name'    => _x('Categories', 'taxonomy general name'), 
     'singular_name'  => _x('Category', 'taxonomy singular name'), 
     'search_items'  => __('Search Categories'), 
     'all_items'   => __('All Categories'), 
     'parent_item'  => __('Parent Category'), 
     'parent_item_colon' => __('Parent Category:'), 
     'edit_item'   => __('Edit Category'), 
     'update_item'  => __('Update Category'), 
     'add_new_item'  => __('Add New Category'), 
     'new_item_name'  => __('New Category'), 
     'menu_name'   => __('Categories'), 
    ); 
    $args = array(
     'labels' => $labels, 
     'hierarchical' => true, 
    ); 
    register_taxonomy('portfolio_category', 'portfolio', $args); 
} 
add_action('init', 'portfolio_taxonomies', 0); 

?> 

的思想,观点,意见将是很有益的,我认为这是公平地说,我们是双方都难倒了这一点。

回答

0

这可能听起来很愚蠢,但将您的固定链接重置为默认链接,然后回到所需的格式。 .htaccess文件所需要的类型后已加入的functions.php后

你的行动重写选项被设置为可能会造成一个问题,也是被改写。如果WP在重写yourdomain.com/page/2/时不清楚,请将其改写为true使其成为yourdomain.com/portfolio/page/2/

其他一切似乎都是按照您的查询进行的。

相关问题