php 为主题添加页眉,页脚和部件支持(Themer)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 为主题添加页眉,页脚和部件支持(Themer)相关的知识,希望对你有一定的参考价值。

<?php // Do not copy this line, start with line 3 

add_filter( 'fl_theme_builder_part_hooks', 'my_theme_register_part_hooks' );

function my_theme_register_part_hooks() {
  return array(
    array(
      'label' => 'Header',
      'hooks' => array(
        'genesis_before_header' => 'Before Header',
        'genesis_after_header'  => 'After Header',
      )
    ),
    array(
      'label' => 'Content',
      'hooks' => array(
        'genesis_before_content' => 'Before Content',
        'genesis_after_content'  => 'After Content',
      )
    ),
    array(
      'label' => 'Footer',
      'hooks' => array(
        'genesis_before_footer' => 'Before Footer',
        'genesis_after_footer'  => 'After Footer',
      )
    )
  );
}
<?php // Do not copy this line, start with line 3 

add_action( 'after_setup_theme', 'my_theme_header_footer_support' );

function my_theme_header_footer_support() {
  add_theme_support( 'fl-theme-builder-headers' );
  add_theme_support( 'fl-theme-builder-footers' );
  add_theme_support( 'fl-theme-builder-parts' );
}
<?php // Do not copy this line, start with line 3 

add_action( 'wp', 'my_theme_header_footer_render' );

function my_theme_header_footer_render() {
  // Get the header ID.
  $header_ids = FLThemeBuilderLayoutData::get_current_page_header_ids();
	
  // If we have a header, remove the theme header and hook in Theme Builder's.
  if ( ! empty( $header_ids ) ) {
    remove_action( 'genesis_header', 'genesis_do_header' );
    add_action( 'genesis_header', 'FLThemeBuilderLayoutRenderer::render_header' );
  }

  // Get the footer ID.
  $footer_ids = FLThemeBuilderLayoutData::get_current_page_footer_ids();

  // If we have a footer, remove the theme footer and hook in Theme Builder's.
  if ( ! empty( $footer_ids ) ) {
    remove_action( 'genesis_footer', 'genesis_do_footer' );
    add_action( 'genesis_footer', 'FLThemeBuilderLayoutRenderer::render_footer' );
  }
}
<?php // Do not copy this line, start with line 3 

add_action( 'after_setup_theme', 'my_theme_header_footer_support' );

function my_theme_header_footer_support() {
  add_theme_support( 'fl-theme-builder-headers' );
  add_theme_support( 'fl-theme-builder-footers' );
}
<?php // Do not copy this line, start with line 3 

remove_action( 'genesis_header', 'genesis_do_header' );

以上是关于php 为主题添加页眉,页脚和部件支持(Themer)的主要内容,如果未能解决你的问题,请参考以下文章

php Sage&WooCommerce |页眉,页脚和侧边栏重复

php Sage&WooCommerce |页眉,页脚和侧边栏重复

在 SwiftUI WebView 中自定义内容(添加页脚和页眉注释)

带有 % extends 的每页上的 Django 页脚和页眉

reportlab 中的多行(段落)页脚和页眉

如何为wordpress主题添加自定义页眉和页脚