dongsetan3216
2016-08-22 12:55
浏览 10
已采纳

将wordpress页面链接到php文件无效

I got a wordpress page called "Galerie". I'd like to display some content on this page. So I createda php file called "content-galerie.php" and wrote some content in it. But the content is not displaying at all. It only displays the default page with the header, the title and the footer. How can i fix that? So my content gets displayed? For example a simple Text

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

图片转代码服务由CSDN问答提供 功能建议

我有一个名为“Galerie”的wordpress页面。 我想在此页面上显示一些内容。 所以我创建了一个名为“content-galerie.php”的php文件并在其中写了一些内容。 但是内容根本没有显示。 它只显示带有标题,标题和页脚的默认页面。 我该如何解决? 那么我的内容会显示出来吗? 例如一个简单的文本

 &lt; p&gt; Lorem ipsum dolor sit amet consetetur sadipscing ...&lt; / p&gt; 
   
 
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dtid30526 2016-08-22 13:24
    已采纳

    You have to create Page template for gallery section.

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

    After that edit you gallery page from admin and assign this template to your gallery page.

    打赏 评论
  • doutan1970 2016-08-22 13:09

    If you have created "content-galerie.php" page in theme folder then you can that page like this.

    get_template_part('content-galerie');
    
    打赏 评论

相关推荐 更多相似问题