【问题标题】:Keeping WordPress theme and layout when opening custom php file打开自定义 php 文件时保持 WordPress 主题和布局
【发布时间】:2013-11-29 08:52:20
【问题描述】:

我正在尝试将一些定制的 php 文件合并到 WordPress 网站中。 在这些文件中制作了指向其他文件的链接。

<?
    echo "<a href=show.php?x=" . $row['Name'] . ">" $row['Name'] . "</a><br> ";
?>

这适用于 WordPress 的 php-execute 插件。唯一的问题是 show.php 在没有 WordPress 主题和布局的情况下打开。

如何创建一个链接,以便新的 php 文件将在与 WordPress 页面相同布局的相同(侧)栏/框架中打开?

【问题讨论】:

    标签: php wordpress


    【解决方案1】:
    you need to create a custom template for that
    
    The syntax is something like this:
    
    <?php
    /*
    Template Name: My Custom Page
    */
    get_header();
    ?>
    
    Here your HTML coding goes
    
    <?php get_footer(); ?>
    
    This will give you the look and feel you are looking for!!
    

    【讨论】:

    • 是否可以自动继承wordpress的/css?
    • 是的,它将自动继承您包含在 header.php 文件中的所有 css 文件
    【解决方案2】:

    找到了自己的工作

    在 WordPress (page_id=x) 中创建一个页面并包含一个 exec-php 插件。 在页面上包含此代码。

    <? 
    $page_include =$_GET["page_include"];
    include $page_include; 
    ?>
    

    如果您想在 wordpress 中显示自定义页面,请点击以下链接:

    <? 
    echo "<a href=?page_id=x&page_include=" . $page_link . "> link </a>"
    ?>
    

    【讨论】:

      猜你喜欢
      • 2020-03-24
      • 2011-10-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-30
      相关资源
      最近更新 更多