2016-09-27 7 views
1

私はword-pressのカスタムテーマを作成しました。私が「新しいページを追加」と言うと、このページにコンテンツを挿入すると、フッターとヘッダーが表示されますが、そのページのCMSにあるコンテンツにフックします。wordpressの新しいページのカスタムテーマ

は、これは私が持っているものです。私はここで間違ってやっている何page.php

<?php get_header(); ?> 

<div class="row"> 
    <div class="col-sm-12"> 

     <?php 
      if (have_posts()) : while (have_posts()) : the_post(); 

       get_template_part('content', get_post_format()); 

      endwhile; endif; 
     ?> 

    </div> <!-- /.col --> 
</div> <!-- /.row --> 

<?php get_footer(); ?> 

そのなって長い一日。ヒントをお願いしますか?

この新しいページから親ページのようにすることもできますが、ページ属性を持つ唯一のオプションは「デフォルトテンプレート」です。

+0

さて、あなたはあなたが使用して共有されていないテンプレートの一部を、ロードしています。そのテンプレート部分の内容は何ですか?また、私はあなたが[get_post_format](https://codex.wordpress.org/Function_Reference/get_post_format)が行うことを誤解していると思います - それは正しい関数ではありません - おそらくあなたは[get_post_type](https://developer.wordpress.org/reference/functions/get_post_type /)、これは 'content-page.php'のテンプレート名になります –

答えて

0

私の実際の問題は解決しました。だから私は私のワードプレスのための '高度なカスタムフィールド'プラグインを使用しました。これを使用すると、まだコーディングを行う必要があります。

新しいページを追加しました。

このページでは、ヘッダーイメージとコンテンツがありました。したがって、2つのフィールドタイプ "画像 - >フィールドタイプとテキストエリア - >フィールドタイプ"に等しいACF(高度なカスタムフィールド)の場合

フィールド名は私の.phpページテンプレート。

フィールド名:イメージ=ヘッダー画像

フィールド名:(2)テキストエリア=ヘッダ画像テキストトップ(および)ヘッダ画像テキスト著者

(私が必要

私は私のページテンプレートをフックし、私はこのページテンプレートに表示したいフィールドのフックを追加しました。

ページ-stay.php:

<?php 
    /*Template Name: Stay - Parent Page */ 
    get_header(); ?> 



<div id="primary" class="content-area"> 
    <main id="main" class="site-main" role="main"> 

    <?php 
    // Start the loop. 
    while (have_posts()) : the_post(); ?> 

    <article id="post=<?php the_ID(); ?>" <?php post_class(); ?>> 

     <!-- <header class="entry-header"> 
      <?php the_title('<h1 class="entry-title">', '</h1>'); ?> 
     </header>(you can use this if you need your page header to display)--> 

     <div class="enry-content"> 
     <?php 
     $image = get_field('header-image'); 

      if(!empty($image)): ?> 
      <div class="head-image"> 
      <img src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" /> 
       <div class="head-text-box"> 
        <div class="head-text-box-holder"> 
         <p class="headtext-quote"><?php the_field('header-image-text-top'); ?></p> 
         <p class="headtext-author"><?php the_field('header-image-text-bottom'); ?></p> 
        </div> 
       </div> 
      </div> 
     <?php endif; ?> 

    </article> 

    <?php endwhile; ?> 

    </main><!-- .site-main --> 
</div><!-- .content-area --> 

<?php get_footer(); ?> 
0

テンプレート部分がない場合は、 の代わりにthe_content()を使用してください。get_template_part( 'content'、get_post_format());

関連する問題