0
我一直在閱讀和搜索整晚。我之前在CPT分頁方面遇到過問題,但這真的讓我發瘋。我將我正在構建的網站上傳到http://koovay.com/Kingship/。 當前版本3.7.1。我原來的代碼是:WordPress中不尋常的自定義帖子類型分頁問題?
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query('showposts=20&post_type=portfolio'.'&paged='.$paged); ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post();
$featuredImage = wp_get_attachment_url(get_post_thumbnail_id($post->ID));
$permalink = get_permalink($id);
?>
- 環路的東西 -
<?php endwhile; ?>
<nav class="paged text-center">
<?php previous_posts_link('« Newer') ?>
<?php next_posts_link('Older »') ?>
</nav>
<?php
$wp_query = null;
$wp_query = $temp; // Reset
?>
進出口使用自定義文章類型的用戶界面和創建了CPT這樣:
add_action('init', 'cptui_register_my_cpt_portfolio');
function cptui_register_my_cpt_portfolio() {
register_post_type('portfolio', array(
'label' => 'Portfolio',
'description' => 'Your portfolio for showcasing yo bitch ass work!',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'rewrite' => array('slug' => 'works', 'with_front' => 1),
'query_var' => true,
'has_archive' => true,
'menu_position' => '5',
'supports' => array('title','editor','thumbnail'),
'taxonomies' => array('category'),
'labels' => array (
'name' => 'Portfolio',
'singular_name' => 'Work',
'menu_name' => 'Portfolio',
'add_new' => 'Add Work',
'add_new_item' => 'Add New Work',
'edit' => 'Edit',
'edit_item' => 'Edit Work',
'new_item' => 'New Work',
'view' => 'View Work',
'view_item' => 'View Work',
'search_items' => 'Search Portfolio',
'not_found' => 'No Portfolio Found',
'not_found_in_trash' => 'No Portfolio Found in Trash',
'parent' => 'Parent Work',
)
)); }
我閱讀了有關帖子將重寫名稱更改爲除CPT名稱以外的其他名稱,因此我將其更改爲「工作」。
但是,這引發了一個404。我試過幾個ALT。運行循環和分頁的版本我可以發佈。
老實說,我真的希望有人能夠給我一些幫助。瘋了... 謝謝!