Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何创建在WordPress中使用PHP代码的页面模板?_Php_Wordpress_Containers - Fatal编程技术网

如何创建在WordPress中使用PHP代码的页面模板?

如何创建在WordPress中使用PHP代码的页面模板?,php,wordpress,containers,Php,Wordpress,Containers,以下是我用于为我的网站的特定页面创建模板的代码。因为这是一个会前活动,也是一个独立的活动,所以我需要设计一个与我在主页上使用的页面略有不同的页面 因此,我复制了page.php并尝试修改模板 我想: 我需要在WordPress页面的页面中使用PHP代码(因为我需要从数据库中执行一些查询并在当前页面中打印) 左侧边栏应该是导航菜单(自定义) 也许这是粗糙的: 从模板中删除head tag和body tag,并在自定义模板中使用默认header函数。这对我@Ashtatel没有帮助 <?p

以下是我用于为我的网站的特定页面创建模板的代码。因为这是一个会前活动,也是一个独立的活动,所以我需要设计一个与我在主页上使用的页面略有不同的页面

因此,我复制了page.php并尝试修改模板

我想:

  • 我需要在WordPress页面的页面中使用PHP代码(因为我需要从数据库中执行一些查询并在当前页面中打印)

  • 左侧边栏应该是导航菜单(自定义)

    也许这是粗糙的:

    
    
    从模板中删除head tag和body tag,并在自定义模板中使用默认header函数。这对我@Ashtatel没有帮助
    <?php
        /**
         * Template Name:theme-meeting-template
         * This template will only display the content you entered in the page editor
         */
    ?>
    
    <?php
        /**
         * The template for displaying all pages.
         *
         * 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 panoramic
         */
    ?>
    
    <html <?php language_attributes(); ?>>
    
    <head>
        <meta charset="<?php bloginfo( 'charset' ); ?>">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="profile" href="http://gmpg.org/xfn/11">
        <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>">
    
        <?php wp_head(); ?>
    
        <div class="theme-head">
            <h1> The Fourth DAE-BRNS Theme Meeting on
                 Generation and use of Covariance
                 Matrices in the Applications of Nuclear Data</h1>
    
            <h2> December 09-13, 2017 </h2>
            <h2> Manipal University, Manipal, India </h2>
        </div>
    
        <div class="hor-nav" style="color: red; margin-top:20px; display: block">
            <ul>
                <li >
                    <a href="http://iclaa2017.com/test-template/">
                    home
                    </a>
                </li>
                <li >
                    <a href="#meetings">
                    Meetings </a>
                </li>
            </ul>
        </div>
    </head>
    
    <body <?php body_class(); ?>>
        <?php
            get_sidebar();
        ?>
    
        <div id="content" class="site-content site-container" >
    
            <?php if ( ! is_front_page() ) : ?>
    
                <?php if ( function_exists( 'bcn_display' ) ) : ?>
                <div class="breadcrumbs">
                    <?php bcn_display(); ?>
                </div>
                <?php endif; ?>
    
            <?php endif; ?>
    
            <div id="primary" class="content-area">
    
                <main id="main" class="site-main" role="main">
    
                    <?php get_template_part( 'library/template-parts/page-title' ); ?>
    
                    <?php while ( have_posts() ) : the_post(); ?>
    
                        <?php get_template_part( 'library/template-parts/content', 'page' ); ?>
    
                        <?php
                            // If comments are open or we have at least one comment, load up the comment template
                            if ( comments_open() || get_comments_number() ) :
                                comments_template();
                            endif;
                        ?>
    
                    <?php endwhile; // End of the loop. ?>
    
                </main><!-- #main -->
            </div><!-- #primary -->
    
        <?php get_footer(); ?>