0

i am using this code to create a new page when my plugin is activated:

        function create_policy() {
     $my_post = array(
      'post_title'    => 'mobile page',
      'post_content'  => 'this is my content',
      'comment_status' => 'closed',
      'post_type'     => 'page',
      'post_status'   => 'publish',
      'post_author'   => 1,
      'post_category' => array( 3,4 )
      );
      wp_insert_post( $my_post );
    }


register_activation_hook( __FILE__, 'create_policy' );

what i want to do is : 1) use my own code in the 'post_content', not regular text. 2) clear all the page and leave only the GET_header i want a blank page with my code.

any advice ?

in addition to the comments:

this is the admin pannel code:

<?php

// create custom plugin settings menu  
add_action('admin_menu', 'zeev_create_menu');  

function zeev_create_menu() {  

    //create new top-level menu  
    add_menu_page('zeev movile redirect', 'zeev mobile', 'administrator', __FILE__, 'zeev_settings_page', 'favicon.ico');  

    //call register settings function  
    add_action( 'admin_init', 'register_mysettings' );  
}  
function register_mysettings() {  
    //register our settings  
    register_setting( 'zeev-settings-group', 'zeev_tracking_code' );  
} 
function zeev_settings_page() {  
?>  
<div class="wrap">  

<form method="post" action="options.php">  

    <?php settings_fields('zeev-settings-group'); ?>  
    <table class="form-table">  

        <tr valign="top">  
        <td><textarea name="zeev_tracking_code" cols="90"><?php echo get_option('zeev_tracking_code'); ?></textarea></td>  
        </tr>  

    </table>  

    <p class="submit">  
    <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />  
    </p>  

</form>  
</div>  
<?php }

and this is the veriable what need to find himself on a blank page someware (and to work)

<?php echo get_option('zeev_tracking_code'); ?>
4

1 回答 1

0

有几种方法可以在 Wordpress 中逐页获取自定义布局,但最常见的是创建新的自定义模板。在主题文件夹中,创建一个名为你喜欢的新文件:

my-custom-template.php

最简单的开始方法是将您找到的内容复制page.php到该目录中。这将为您提供具有有用的页眉和页脚的结构。在文件的顶部,输入:

<?php
/*
*
* Template Name: [My template]
*
*/
?>

这样做会告诉 WP 在创建新页面时自动将此模板作为选项。现在,当您创建页面时,您可以从下拉列表中选择此模板,该页面将使用该模板。在模板本身内部,您可以将所需的任何 PHP 或 HTML 代码放在您喜欢的中间get_header()get_footer()以设置样式,或仅显示您的两个按钮。

如果您想要一个完全空白的页面,您可以完全删除get_header()and get_footer()

于 2013-05-31T15:23:21.393 回答