내 포트폴리오의 포트폴리오를 표시하기 위해 사용자 정의 게시 유형을 만들었습니다. 사용자가 프로젝트를 클릭하면 프로젝트 세부 정보를 표시하려고합니다.사용자 정의 게시 유형 최근 게시물 만 표시
단일 프로젝트 세부 정보 페이지에서 사용자가 프로젝트 전후에 게시 된 프로젝트를 탐색 할 수 있기를 원하지만 올바르게 작업 할 수없는 페이지 매김을 얻을 수 없습니다.
내 루프는 내가가는 링크가 무엇이든 가장 최근의 게시물 만 표시하므로 그 이유를 알 수 없습니다. 이것이 제 페이지 매김 문제의 문제라고 생각합니다. 어떤 도움을 주셔서 감사합니다.
내가 비디오를 포함 한 것을 경험 메신저 : https://gyazo.com/4f148154e05bc205fd78bdde89de50c3
당신은 내가 "테스트 프로젝트 1"에이고는 "테스트 2"내용을 표시하는 것 볼 수 있듯이. 또한, 테스트 프로젝트 1 (가장 오래된 포스트 인) 매김 대신 시험 2 (새로운 포스트)
단일 project.php
<?php
$mypost = array('post_type' => 'project', 'posts_per_page' => 1,);
$loop = new WP_Query($mypost);
?>
<?php while ($loop->have_posts()) : $loop->the_post();?>
<div class="col-lg-8" id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_content(); ?>
</div>
<div class="col-lg-4">
<h3><?php the_title(); ?></h3>
<p><?php the_excerpt(); ?></p>
<h5>Date</h5>
<p><?php the_date(); ?></p>
<h5>Link</h5>
<p>
<?php $site= get_post_custom_values('project_link_detail');
if($site[0] != ""){
?>
<a href="http://<?php echo esc_html(get_post_meta(get_the_ID(), 'project_link_detail', true)); ?>" target="_blank">Visit the Site</a>
<?php }else{ ?>
<em>Link Unavailable</em>
<?php } ?>
</div>
<hr>
<div class="col-lg-12">
<div class="row">
<div class="col-lg-6">
<?php previous_post_link('%link') ?>
</div>
<div class="col-lg-6 text-right">
<?php next_post_link(' %link') ?>
</div>
</div>
</div>
<?php endwhile; ?>
portfolio.php
동일한 페이지 나 연출에function my_portfolio() {
// Set the labels, this variable is used in the $args array
$labels = array(
'name' => __('Projects'),
'singular_name' => __('Project'),
'add_new' => __('Add New Project'),
'add_new_item' => __('Add New Project'),
'edit_item' => __('Edit Project'),
'new_item' => __('New Project'),
'all_items' => __('All Projects'),
'view_item' => __('View Project'),
'search_items' => __('Search Project'),
'featured_image' => 'Preview',
'set_featured_image' => 'Add Preview'
);
// The arguments for our post type, to be entered as parameter 2 of register_post_type()
$args = array(
'labels' => $labels,
'description' => 'Holds portfolio specific data',
'public' => true,
'menu_position' => 25,
'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields'),
'has_archive' => true,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'has_archive' => 'page template',
'rewrite' => true,
'query_var' => 'project'
);
// Call the actual WordPress function
// Parameter 1 is a name for the post type
// Parameter 2 is the $args array
register_post_type('project', $args);
}
와우! Underscores.me는 대단히 감사합니다. 결국 문제를 파악하고 사용자 지정 쿼리를 제거하고 archive- {posttype} .php 및 single- {post-type} .php를 사용하여 자동 매핑 된 쿼리를 사용했습니다. 다시 한 번 감사드립니다! – Nick
예, 그 멋진 도구, 당신이 이것을 해결하는 방법을 찾은 것을 기쁘게 생각합니다. – ecastellano