How to create a page template which takes php code

2019-09-14 00:51发布

问题:

The following is the code I have used for creating a template for a particular page of my website. Since, its a pre-conference and an independent event. I need to design this page slightly different from what I have used for the home page.

so, I have copied the page.php and try to modify the template.

What I want is.

  1. I need to use the php codes in the page in the wordpress page(because i need to do some query from my database and print it in the current page).

  2. left sidebar should be the navigation menu(custom).

May be this is the rough.

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

Kindly click here for the output