2017-12-28 12 views
0

사용자 정의 게시물 유형의 게시물을 표시하려하지만 아무 것도 표시하지 않습니다.게시물 유형별 쿼리 - 아무 것도 표시되지 않습니다.

모든 사용자 정의 필드를 CPT UI/ACF로 설정했는데 표시 장치가 될 때까지 모든 것이 부드럽게 보입니다.

<?php 
/** 
* Template Name: Blog template 
* 
* @package Hestia 
* @since Hestia 1.0 
*/ 

get_header(); 
?> 

<?php 

$args = array(
    'post_type' => 'blog', 
    'posts_per_page' => 10); 
    $loop = new WP_Query($args); 
?> 


<?php while ($loop->have_posts()) : $loop->the_post(); ?> 

    <h1><?php the_field('main_title');?><h1> 
    <img src="<?php the_field('header_image');?>" alt="" /> 
    <p><?php the_field('paragraph_1');?></p> 
    <img src="<?php the_field('image_1');?>" alt="" /> 
    <p><?php the_field('paragraph_2');?><h1> 
    <img src="<?php the_field('image_2');?>" alt="" /> 
    <p><?php the_field('paragraph_3');?><h1> 
    <img src="<?php the_field('image_3');?>" alt="" /> 



<?php endwhile; ?> 

    <?php get_footer(); ?> 

function cptui_register_my_cpts_blog() { 

    /** 
    * Post Type: Blog. 
    */ 

    $labels = array(
     "name" => __("Blog", "hestia-pro"), 
     "singular_name" => __("blog", "hestia-pro"), 
     "menu_name" => __("Blog", "hestia-pro"), 
     "all_items" => __("All posts", "hestia-pro"), 
     "add_new" => __("Add new", "hestia-pro"), 
     "add_new_item" => __("Add new post", "hestia-pro"), 
    ); 

    $args = array(
     "label" => __("Blog", "hestia-pro"), 
     "labels" => $labels, 
     "description" => "", 
     "public" => true, 
     "publicly_queryable" => true, 
     "show_ui" => true, 
     "show_in_rest" => false, 
     "rest_base" => "", 
     "has_archive" => false, 
     "show_in_menu" => true, 
     "exclude_from_search" => false, 
     "capability_type" => "post", 
     "map_meta_cap" => true, 
     "hierarchical" => false, 
     "rewrite" => array("slug" => "blog", "with_front" => true), 
     "query_var" => true, 
     "menu_icon" => "dashicons-welcome-write-blog", 
     "supports" => array("title", "editor", "thumbnail"), 
    ); 

    register_post_type("blog", $args); 
} 

add_action('init', 'cptui_register_my_cpts_blog'); 

'post_type'가 정확하고 동일한 필드 이름을 간다 :

이것은 내가 만든 blog.php 템플릿입니다. 모두 맞춤 입력란과 일치하지만 어떤 이유로 든 아무 것도 표시되지 않습니다.

감사합니다.

답변

0

has_archive를 true로 설정하십시오. 같은 문제가 있었는데이 문제가 해결되었습니다.

+0

답장을 보내 주셔서 감사합니다.하지만 슬프게도 문제가 해결되지 않았습니다./ –

+0

데이터가 유효합니까? (귀하의 URL)/블로그를 입력하고 데이터를 가져올 수 있습니까? – teebark

관련 문제