2016-08-22 110 views
0

我收到了一個名爲「Galerie」的wordpress頁面。我想在此頁面上顯示一些內容。所以我創建了一個名爲「content-galerie.php」的php文件,並在其中寫入了一些內容。 但內容完全不顯示。它只顯示標題,標題和頁腳的默認頁面。 我該如何解決這個問題?所以我的內容顯示? 例如一個簡單的文本將wordpress頁面鏈接到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-page,fixed_container)。 你可以用這個類替換你的類。 打開你的「Page.php」並遵循相同的類結構。 – Dinesh

0

如果在主題文件夾中創建「內容galerie.php」頁面,那麼你可以像這樣的頁面。

get_template_part('content-galerie'); 
+0

我該在哪裏添加此代碼?我將它添加到我的「content-galerie.php」中,它仍然沒有顯示任何內容 –

+0

將此文件放在主題文件夾中,並將此代碼寫入要顯示內容的文件中。 – Dinesh

+0

該文件已經在主題文件夾中。但我想在content-galerie.php文件中寫入一些內容,並且它不會在網頁上顯示任何內容...... [link](http://gartenlustig.ch/galerie/)就像您在該頁面上看到的那樣 –