dongqiaogouk86049 2017-02-04 11:29
浏览 43

如何创建一个在wordpress中使用php代码的页面模板?

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. enter image description here

<?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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料