doufuxing8562 2012-05-07 17:53
浏览 69
已采纳

使用自己的自定义脚本将自己的自定义页面添加到Wordpress

I wish to add a custom page to wordpress, not in the usual sort of way. This page has my own custom script and functions and to develop a plugin is beyond my means so I was wondering if this is possible:

Suppose I were to build it on the existing page.php script in my there folder, my script looks something like this:

<?php get_header(); ?>
                        <div id="left-area" class="clearfix">
                                <?php 

                                //My script would go here 

                                ?>

                                <div class="comments">
                                        <?php comments_template('',true); ?>
                                </div><!-- end of comments div -->             

                        </div><!-- end of left-area -->
                        <!-- LEFT AREA ENDS HERE -->

    <?php get_sidebar(); ?>

<?php get_footer(); ?>

Is this even possible? I tried and got a page not found error. And if so, how do I call this script assuming WP is installed in the root directory? Example: www.mysite.com/myscript

  • 写回答

1条回答 默认 最新

  • dpp42324 2012-05-07 18:34
    关注

    Absolutely. Duplicate page.php. Rename it to template_mine.php. Open to edit, and before the get_header tag, add:

    <?php 
    //
    // Template Name: My Custom template (choose something more descriptive, like contact page)
    // 
    ?>
    

    Go to Wordpress dashboard for pages, create a new page with your title, and in the Page attributes on the right hand side, under templates, select your template name, update, and you are all set.

    Reference: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

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

报告相同问题?

悬赏问题

  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题