簡體   English   中英

將WordPress頁面鏈接到PHP文件不起作用

[英]Link wordpress page to php file not working

我有一個名為“ Galerie”的WordPress頁面。 我想在此頁面上顯示一些內容。 因此,我創建了一個名為“ content-galerie.php”的php文件,並在其中寫入了一些內容。 但是內容根本沒有顯示。 它僅顯示帶有頁眉,標題和頁腳的默認頁面。 我該如何解決? 這樣我的內容被顯示了嗎? 例如一個簡單的文本

<p>Lorem ipsum dolor sit amet consetetur sadipscing...</p>

您必須為庫部分創建頁面模板。

<?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(); ?>

完成該編輯后,您可以從admin中瀏覽圖庫頁面,並將此模板分配給您的圖庫頁面。

如果在主題文件夾中創建了“ content-galerie.php”頁面,則可以像這樣創建該頁面。

get_template_part('content-galerie');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM