doubei3312 2014-03-18 06:20
浏览 91
已采纳

Wordpress自定义页面代码

I'm very new to wordpress and was just wondering if anyone could point me in the direction of a tutorial which will explain how to add my own code to wordpress pages.

So far all that I've been able to find is that I'm supposed to copy the page.php from my template and use that as the template for a page added in wordpress. This however only gives me control over the body and not the header/nav menu/sidebar.

Am I correct is assuming I must replace the method calls such as get_header(), etc with the code it would generate and manipulate it from there? Also is it correct if I change the arguments to get_template_part( 'content', 'page' ); and add a php page with the appropriate name for the body?

  • 写回答

1条回答 默认 最新

  • douteng5673 2014-03-18 07:54
    关注

    Way 1 You can do this:

    1) add new page enter image description here

    2) add these code to index.php or page.php

    <?php
    
    if (is_page('About 3C')) {?>
    
    <div>Display this particular div</div>
    
    <?php }
    
    else { ?>
    
    <div>Display that particular div</div>
    <?php }?>
    

    or

    <?php 
    
    if (is_page('About 3C')) {
    
    <div>Display this particular div</div>
    
    }
    
    else {
    
    <div>Display that particular div</div>
    }
    
    ?>
    

    assume your added page name is: About 3C

    and you can call the database from above code

    OR way 2: please refer: http://line25.com/tutorials/how-to-create-a-wordpress-custom-page-template

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛