[wordpress插件] Default Theme Pages默认主题页面

wordpress 插件 文章 2020-04-14 16:30 468 0 全屏看文

AI助手支持GPT4.0

评分
0
描述

This plugin is intended to be useful for template developers

此插件旨在对模板开发人员有用

New in version 0.4

0.4版的新功能

    • added ‘object’ (page object) in every $default_theme_pages item for fast access.
    • 在每个$ default_theme_pages项目中添加了“对象”(页面对象),以便快速访问。

    • added all default pages to wp toolbar, inside ‘site name’, to increase user experience.
    • 将所有默认页面添加到“网站名称”内的wp工具栏,以提高用户体验。

    How to use

    使用方法

    Add this code in your functions.php.

    将此代码添加到您的 functions.php 中。

    global $default_theme_pages;

      global $ default_theme_pages;

    $default_theme_pages = array(    

    $ default_theme_pages =数组(    

    array(        

    数组(        

    'name' => 'home', // initial slug page / id for templating - access functions        

    'name'=>'home',//用于模板的初始子页面/ id-访问功能        

    'title' => 'Homepage', // page title        

    'title'=>'Homepage',//页面标题        

    'option' => 'page_on_front', // option page id ( stores the page id in an option, use only in theese cases)        

    'option'=>'page_on_front',//选项页面ID(将页面ID存储在选项中,仅在这些情况下使用)        

    'description' => 'homepage' // description    

    'description'=>'主页'//说明    

    ),    

    ),    

    array(        

    数组(        

    'name' => 'blog',        

    '名称'=>'博客',        

    'title' => 'Blog',        

    '标题'=>'博客',        

    'option' => 'page_for_posts',        

    'option'=>'page_for_posts',        

    'description' => 'blog'    

    '描述'=>'博客'    

    ),    

    ),    

    array(        

    数组(        

    'name' => 'contact',        

    '名称'=>'联系人',        

    'title' => 'Contact me!',        

    'title'=>'与我联系!',        

    'description' => 'Contact form page'    

    '说明'=>'联系表格页面'    

    ) 

    );

    );

    Tips

    提示

      • After the pages are created automatically, you can change their title and slug without problem.
      • 自动创建页面后,您可以毫无问题地更改其标题和标签。

      • If you add an option names: page_on_front and page_for_posts, you will block the home-page and

      • 如果添加 option 名称: page_on_front page_for_posts ,则会阻止首页

        the blog-page on your site.

      • 您网站上的博客页面

      Templating

      模板化

      You can template using ID or name (setted up in $default_theme_pages global variable ), something like:

      您可以使用 ID 名称(在$ default_theme_pages全局变量中设置)进行模板化,例如:

      page-131.php or page-contact.php (If you change the page slug, this will still work because 'contact' was defined as

      page-131.php page-contact.php (如果更改页面信息,由于“ contact”被定义为

      pagename if $default_theme_pages global variable).

      pagename (如果是$ default_theme_pages全局变量)。

      For detect if you’re in that page:

      要检测您是否在该页面中:

      dtp_is_page('contact')

        dtp_is_page('contact')

      Getting a default page id:

      获取默认页面ID:

      $page_id = dtp_get_page_id('contact');

        $ page_id = dtp_get_page_id('contact');

      This method is more quick than get_page_by_path because page ID is stored on global variable.

      此方法比 get_page_by_path 更快,因为页面ID存储在全局变量中。

下载地址
https://downloads.wordpress.org/plugin/default-theme-pages.zip
-EOF-

AI助手支持GPT4.0