2017-12-28 20 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

trueにhas_archiveを設定します。同じ問題があって、これが修正されました。

+0

返信いただきありがとうございますが、悲しいことに、解決できませんでした:/ –

+0

データがありますか?あなたは(あなたのURL)/ブログを入力してデータを入手できますか? – teebark

関連する問題