新wordpress主题需要包含哪些默认功能

时间:2015-04-18 05:13:18

标签: wordpress wordpress-plugin wordpress-theming

我正在从头开始创建一个wordpress主题。 我创建了自己的page.php,header.php,footer.php,sinngle.php。

当我安装任何第三方插件时,它不起作用,但适用于任何第三方主题。 我是否需要包含任何预定义的wordpress API才能使其正常工作?

2 个答案:

答案 0 :(得分:1)

是的,您需要在主题中添加几个功能来制作完整的WordPress主题。 首先要仔细阅读。 https://codex.wordpress.org/Theme_Development

一些要点:

  • header.phpwp_head()
  • 之前应该有</head>函数调用
  • footer.phpwp_footer()
  • 之前应该有</body>函数调用
  • 您需要正确使用WordPress循环。 https://codex.wordpress.org/The_Loop
  • 如果您要注册导航,补充工具栏等,则应在functions.php
  • 中完成

答案 1 :(得分:0)

在您的主题页面中显示您的小部件,如下所示:

<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('header_sidebar') ) : 
endif; ?>

您当然可以将上面的dynamic_sidebar替换为您要集成的第三方小部件的实际标记名称。

如果您制作自己的小部件,请在functions.php

中注册

http://wpgyan.com/how-to-create-a-widget-area-in-wordpress-theme/

示例:

<?php
/**
 * Register Widget Area.
 *
 */
function wpgyan_widgets_init() {

    register_sidebar( array(
        'name' => 'Header Sidebar',
        'id' => 'header_sidebar',
        'before_widget' => '<div>',
        'after_widget' => '</div>',
        'before_title' => '<h2 class="rounded">',
        'after_title' => '</h2>',
    ) );
}
add_action( 'widgets_init', 'wpgyan_widgets_init' );
?>