2016-08-22 7 views
0

私は「Galerie」と呼ばれるワードプレスページを手に入れました。このページにいくつかのコンテンツを表示したいと思います。そこで私は "content-galerie.php"というPHPファイルを作成し、そこにいくつかのコンテンツを書きました。 しかし、コンテンツはまったく表示されません。ヘッダー、タイトル、およびフッターを含むデフォルトのページのみが表示されます。 どうすれば修正できますか?だから私のコンテンツは表示されますか?例えば 、単純なテキストWordPressのページをPHPのファイルにリンクできない

あなたがテーマフォルダに「コンテンツgalerie.php」ページを作成している場合
<p>Lorem ipsum dolor sit amet consetetur sadipscing...</p> 

答えて

1

ギャラリーセクションのページテンプレートを作成する必要があります。

<?php 
/** 
* Template Name: Gallery 
* 
* This is the template that displays all pages by default. 
* Please note that this is the WordPress construct of pages and that 
* other "pages" on your WordPress site will use a different template. 
* 
* @package WordPress 
* @subpackage Twenty_Sixteen 
* @since Twenty Sixteen 1.0 
*/ 

get_header(); 

?> 


// You can write your gallery content here 


<section class="section single-page"> 
<div class="fixed_container"> 
    <?php 
    // Start the loop. 
    while (have_posts()) : the_post(); 

     // Include the page content template. 
     get_template_part('template-parts/content', 'page'); 

     // If comments are open or we have at least one comment, load up the comment template. 
     if (comments_open() || get_comments_number()) { 
      comments_template(); 
     } 

     // End of the loop. 
    endwhile; 
    ?> 


</div> 
</section> 

<?php get_footer(); ?> 

その後、管理者からギャラリーページを編集し、このテンプレートをギャラリーページに割り当てます。

+0

ありがとうございます:)その作業!ヘッダーはフッターと内容が重なっています...を追加するか、別の解決策がありますか? –

+0

これは、私が使用しているダミーのクラス(section single-page、fixed_container)です。 あなたはこのクラスをあなたと置き換えることができます。 "Page.php"を開き、同じクラス構造に従ってください。 – Dinesh

0

することができます。このような、そのページ。

get_template_part('content-galerie'); 
+0

どこにこのコードを追加する必要がありますか?私はそれを私の "content-galerie.php"に追加しました。まだ内容を表示していません。 –

+0

このファイルをテーマのフォルダに入れ、コンテンツを表示したいファイルにこのコードを書いてください。 – Dinesh

+0

ファイルはすでにテーマフォルダにあります。しかし、私はcontent-galerie.phpファイルにいくつかのコンテンツを書きたいと思いますし、Webページ上に何も表示していません... [link](http://gartenlustig.ch/galerie/)そのページのように –

関連する問題