Astra WordPress钩子参考大全
解决方案
完整的Astra WordPress钩子参考
目录
- WooCommerce产品页(单一商品)
- WooCommerce归档/商店
- 页眉与导航
- 页脚
- 内容与容器
- 归档与分页
- 单篇文章/博客
- 评论
- 侧边栏
- 相关文章
- EDD(Easy Digital Downloads)
- 管理与定制器
- 其他
WooCommerce产品页
单一商品页钩子 - 这些钩子在单个商品页面触发,前缀为 astra_woo_single_*
产品信息显示
astra_woo_single_title_before - Before product title
astra_woo_single_title_after - After product title
astra_woo_single_price_before - Before product price
astra_woo_single_price_after - After product price
astra_woo_single_rating_before - Before product rating
astra_woo_single_rating_after - After product rating
astra_woo_single_short_description_before - Before short description
astra_woo_single_short_description_after - After short description
文件: inc/compatibility/woocommerce/class-astra-woocommerce.php
购买与加入购物车
astra_woo_single_add_to_cart_before - Before add to cart button
astra_woo_single_add_to_cart_after - After add to cart button
astra_woo_single_product_payments_before - Before payment options
astra_woo_single_product_payments_after - After payment options
其他元素
astra_woo_single_extras_before - Before extra content
astra_woo_single_extras_after - After extra content
astra_woo_single_category_before - Before category info
astra_woo_single_category_after - After category info
astra_woo_single_product_category_before - Before product category
astra_woo_single_product_category_after - After product category
WooCommerce商店/归档
归档/分类页钩子 - 这些钩子在产品归档页和分类页上触发,前缀为 astra_woo_shop_*
产品摘要包装
astra_woo_shop_before_summary_wrap - Before product summary wrapper
astra_woo_shop_summary_wrap_top - Top of product summary wrapper
astra_woo_shop_summary_wrap_bottom - Bottom of product summary wrapper
astra_woo_shop_after_summary_wrap - After product summary wrapper
产品信息
astra_woo_shop_title_before - Before product title
astra_woo_shop_title_after - After product title
astra_woo_shop_price_before - Before product price
astra_woo_shop_price_after - After product price
astra_woo_shop_rating_before - Before product rating
astra_woo_shop_rating_after - After product rating
astra_woo_shop_short_description_before - Before short description
astra_woo_shop_short_description_after - After short description
加入购物车
astra_woo_shop_add_to_cart_before - Before add to cart button
astra_woo_shop_add_to_cart_after - After add to cart button
分类法
astra_woo_shop_category_before - Before category display
astra_woo_shop_category_after - After category display
文件: inc/compatibility/woocommerce/woocommerce-common-functions.php
页眉与布局
页眉结构
astra_above_header - Above main header
astra_primary_header - Primary header area
astra_below_header - Below main header
astra_header_before - Before header wrapper
astra_header - Main header
astra_header_after - After header wrapper
astra_header_markup_before - Before header markup
astra_header_markup_after - After header markup
页眉组件
astra_site_identity - Site logo/identity
astra_header_button_1 - Header button 1
astra_header_menu_1 - Header menu 1
astra_header_menu_2 - Header menu 2
astra_header_menu_mobile - Mobile header menu
astra_header_html_1 - Header custom HTML 1
astra_header_html_2 - Header custom HTML 2
astra_header_search - Header search
astra_header_social_1 - Header social icons
astra_header_mobile_trigger - Mobile menu trigger
astra_header_account - Header account link
astra_header_woo_cart - WooCommerce header cart
astra_header_edd_cart - Easy Digital Downloads cart
购物车图标
astra_woo_header_cart_icons_before - Before WooCommerce cart icons
astra_woo_header_cart_icons_after - After WooCommerce cart icons
astra_edd_header_cart_icons_before - Before EDD cart icons
astra_edd_header_cart_icons_after - After EDD cart icons
移动端页眉
astra_mobile_header_bar_top - Top of mobile header bar
astra_mobile_above_header - Mobile header above
astra_mobile_primary_header - Mobile primary header
astra_mobile_below_header - Mobile header below
astra_mobile_header - Main mobile header
astra_mobile_header_content - Mobile header content popup
动态页眉行
astra_header_{$row}_container_before - Before header row (dynamic)
astra_header_{$row}_container_after - After header row (dynamic)
astra_render_header_column - Render header column
astra_render_mobile_header_column - Render mobile header column
astra_render_header_components - Render header components
文件:
template-parts/header/builder/desktop-builder-layout.phptemplate-parts/header/builder/mobile-builder-layout.phptemplate-parts/header/builder/components.php
页脚
页脚结构
astra_above_footer - Above footer
astra_primary_footer - Primary footer area
astra_below_footer - Below footer
astra_footer_before - Before footer wrapper
astra_footer - Main footer
astra_footer_after - After footer wrapper
astra_footer_content_top - Top of footer content
astra_footer_content - Footer content area
astra_footer_content_bottom - Bottom of footer content
页脚组件
astra_footer_copyright - Footer copyright
astra_footer_social_1 - Footer social icons
astra_footer_html_1 - Footer custom HTML 1
astra_footer_html_2 - Footer custom HTML 2
astra_footer_menu - Footer menu
astra_footer_divider_1 - Footer divider
动态页脚行
astra_footer_{$row}_container_before - Before footer row (dynamic)
astra_footer_{$row}_container_after - After footer row (dynamic)
astra_render_footer_column - Render footer column
astra_render_footer_components - Render footer components
文件:
template-parts/footer/builder/desktop-builder-layout.phptemplate-parts/footer/builder/footer-row.php
内容与容器
主要内容区域
astra_content_before - Before main content area
astra_content_after - After main content area
astra_content_top - Top of content
astra_content_bottom - Bottom of content
astra_primary_content_top - Top of primary content
astra_primary_content_bottom - Bottom of primary content
条目/文章内容
astra_entry_before - Before post entry
astra_entry_after - After post entry
astra_entry_top - Top of entry
astra_entry_bottom - Bottom of entry
astra_entry_content_before - Before entry content
astra_entry_content_after - After entry content
内容类型
astra_entry_content_single - Single post content
astra_entry_content_single_page - Single page content
astra_entry_content_404_page - 404 page content
astra_entry_content_blog - Blog post content
归档与分页
归档标题
astra_archive_header - Archive page header
astra_before_archive_title - Before archive title
astra_after_archive_title - After archive title
astra_before_archive_breadcrumb - Before breadcrumb
astra_after_archive_breadcrumb - After breadcrumb
astra_before_archive_description - Before archive description
astra_after_archive_description - After archive description
归档条目显示
astra_archive_entry_header_before - Before entry header
astra_archive_entry_header_after - After entry header
astra_archive_post_meta_before - Before post meta
astra_archive_post_meta_after - After post meta
astra_archive_post_title_before - Before post title
astra_archive_post_title_after - After post title
博客归档
astra_blog_archive_featured_image_before - Before featured image
astra_blog_archive_featured_image_after - After featured image
astra_blog_archive_category_before - Before category
astra_blog_archive_category_after - After category
astra_blog_archive_tag_before - Before tag
astra_blog_archive_tag_after - After tag
astra_blog_archive_title_before - Before title
astra_blog_archive_title_after - After title
astra_blog_archive_title_meta_before - Before title meta
astra_blog_archive_title_meta_after - After title meta
astra_blog_archive_excerpt_before - Before excerpt
astra_blog_archive_excerpt_after - After excerpt
astra_blog_archive_read_more_before - Before read more button
astra_blog_archive_read_more_after - After read more button
astra_blog_archive_breadcrumb_before - Before breadcrumb
astra_blog_archive_breadcrumb_after - After breadcrumb
astra_blog_archive_description_before - Before description
astra_blog_archive_description_after - After description
分页
astra_pagination - Pagination output
单篇文章横幅
横幅包装器
astra_single_post_banner_before - Before banner
astra_single_post_banner_after - After banner
横幅组件
astra_single_post_banner_breadcrumb_before - Before breadcrumb
astra_single_post_banner_breadcrumb_after - After breadcrumb
astra_single_post_banner_title_before - Before title
astra_single_post_banner_title_after - After title
astra_single_post_banner_excerpt_before - Before excerpt
astra_single_post_banner_excerpt_after - After excerpt
astra_single_post_banner_meta_before - Before meta
astra_single_post_banner_meta_after - After meta
astra_single_post_banner_taxonomies_before - Before taxonomies
astra_single_post_banner_taxonomies_after - After taxonomies
astra_blog_single_featured_image_before - Before featured image
astra_blog_single_featured_image_after - After featured image
单一页眉
astra_single_header_before - Before single header
astra_single_header_after - After single header
astra_single_header_top - Top of single header
astra_single_header_bottom - Bottom of single header
评论
astra_comments_before - Before comments section
astra_comments_after - After comments section
astra_after_comments_module - After comments module
侧边栏
astra_sidebars_before - Before sidebars
astra_sidebars_after - After sidebars
相关文章
astra_related_posts_loop_before - Before related posts loop
astra_related_posts_loop_after - After related posts loop
astra_related_posts_title_before - Before related posts title
astra_related_posts_title_after - After related posts title
astra_related_post_before_featured_image - Before featured image
astra_related_post_after_featured_image - After featured image
astra_related_post_before_title - Before post title
astra_related_post_after_title - After post title
astra_related_post_before_excerpt - Before excerpt
astra_related_post_after_excerpt - After excerpt
astra_related_post_before_cta - Before CTA button
astra_related_post_after_cta - After CTA button
文件: inc/modules/related-posts/class-astra-related-posts-markup.php
EDD钩子
Easy Digital Downloads产品页
归档块包装器
astra_edd_archive_before_block_wrap - Before product block
astra_edd_archive_block_wrap_top - Top of block
astra_edd_archive_block_wrap_bottom - Bottom of block
astra_edd_archive_after_block_wrap - After block
产品信息
astra_edd_archive_title_before - Before title
astra_edd_archive_title - Title
astra_edd_archive_title_after - After title
astra_edd_archive_image_before - Before image
astra_edd_archive_image - Image
astra_edd_archive_image_after - After image
astra_edd_archive_price_before - Before price
astra_edd_archive_price - Price
astra_edd_archive_price_after - After price
astra_edd_archive_short_description_before - Before description
astra_edd_archive_short_description - Description
astra_edd_archive_short_description_after - After description
操作
astra_edd_archive_add_to_cart_before - Before add to cart
astra_edd_archive_add_to_cart - Add to cart
astra_edd_archive_add_to_cart_after - After add to cart
分类
astra_edd_archive_category_before - Before category
astra_edd_archive_category - Category
astra_edd_archive_category_after - After category
文件:
inc/compatibility/edd/edd-common-functions.phpinc/compatibility/edd/class-astra-edd.php
管理与定制器
主题更新
astra_update_initiated - When update starts
astra_theme_update_before - Before theme update
astra_theme_update_after - After theme update
astra_batch_process_task_* - Batch process tasks (dynamic)
astra_database_migration_complete - After database migration
管理通知
astra_notice_before_markup - Before notice markup
astra_notice_before_markup_{id} - Before specific notice (dynamic)
astra_notice_inside_markup_{id} - Inside specific notice (dynamic)
astra_notice_after_markup_{id} - After specific notice (dynamic)
astra_notice_after_markup - After notice markup
自定义器
astra_customizer_font_list - Font list in customizer
astra_customizer_save - Customizer save action
astra_style_guide_site_icon - Style guide site icon
其他
文档结构
astra_html_before - Before HTML tag
astra_head_top - Top of head
astra_head_bottom - Bottom of head
astra_body_top - Top of body
astra_body_bottom - Bottom of body
页眉区与标题栏
astra_masthead_top - Top of masthead
astra_masthead - Main masthead
astra_masthead_bottom - Bottom of masthead
astra_masthead_content - Masthead content
astra_main_header_bar_top - Top of main header bar
astra_main_header_bar_bottom - Bottom of main header bar
astra_masthead_toggle_buttons_before - Before toggle buttons
astra_masthead_toggle_buttons - Toggle buttons
astra_masthead_toggle_buttons_after - After toggle buttons
astra_sticky_header_markup - Sticky header
astra_bottom_header_after_markup - After bottom header
内容循环
astra_content_while_before - Before content loop
astra_content_loop - Content loop
astra_content_page_loop - Page loop
astra_content_while_after - After content loop
astra_template_parts_content_top - Top of template content
astra_page_template_parts_content - Page template content
astra_template_parts_content - Template content
astra_template_parts_content_bottom - Bottom of template content
astra_template_parts_content_none - No content found
摘要
astra_the_excerpt_before - Before excerpt
astra_the_excerpt_after - After excerpt
404页面
astra_entry_content_404_page - 404 page content
astra_404_content_template - 404 content template
SureCart
astra_before_archive_surecart_banner_content - Before banner content
astra_after_archive_surecart_banner_content - After banner content
空购物车
astra_empty_cart_before - Before empty cart message
astra_empty_cart_content - Empty cart content
astra_empty_cart_after - After empty cart message
工具
astra_class_loaded - When Astra class loaded
astra_builder_loaded - When builder loaded
astra_learn_progress_saved - When learning progress saved
astra_regenerate_fonts_folder - Regenerate fonts folder
astra_get_fonts - Get fonts action
astra_before_update_option_{option} - Before option update (dynamic)
astra_after_update_option_{option} - After option update (dynamic)
astra_before_delete_option_{option} - Before option delete (dynamic)
astra_after_delete_option_{option} - After option delete (dynamic)
astra_main_header_custom_menu_item_before - Before custom menu item
astra_main_header_custom_menu_item_after - After custom menu item
astra_render_mobile_popup - Render mobile popup
astra_render_desktop_popup - Render desktop popup
Astra Hooks插件 - 自定义器钩子区域
Astra Hooks插件在主题自定义器中提供可编辑的钩子区域:
wp_head - WordPress head section
wp_footer - WordPress footer section
astra_header_before - Before header
astra_header_after - After header
astra_content_before (hook-before-container)
astra_primary_content_top (hook-before-main-content)
astra_entry_top (hook-entry-top)
astra_entry_content_before (hook-entry-content-before)
astra_entry_content_after (hook-entry-content-after)
astra_entry_bottom (hook-entry-bottom)
astra_primary_content_bottom (hook-after-main-content)
astra_content_after (hook-after-container)
astra_comments_before (hook-comments-before)
astra_comments_after (hook-comments-after)
astra_sidebars_before (hook-sidebars-before)
astra_sidebars_after (hook-sidebars-after)
astra_footer_before (hook-footer-before)
astra_footer_after (hook-footer-after)
钩子使用示例
示例1:在产品价格前添加自定义内容
add_action( 'astra_woo_single_price_before', function() {
echo '<div class="custom-content">Special Offer!</div>';
});
示例2:修改产品标题输出
add_filter( 'the_title', function( $title ) {
if ( is_product() ) {
$title = strtoupper( $title );
}
return $title;
}, 10, 1 );
示例3:在商店归档中添加自定义HTML
add_action( 'astra_woo_shop_title_after', function() {
echo '<span class="custom-badge">New</span>';
});
示例4:使用remove_action移除元素
remove_action( 'astra_woo_single_add_to_cart_after', 'some_callback_function' );
备注
- 所有Astra钩子都以
astra_为前缀,便于识别 - 许多钩子以
*_before与*_after成对出现,以实现更高的灵活性 - 有些钩子使用像
{$row}、{$option}这样的动态值,随上下文而变化 - 钩子按照它们在模板文件中出现的顺序进行处理
- 你可以使用
remove_action()移除Astra自身的动作,并用自定义功能替换 - Astra Hooks插件在自定义器中提供一个界面,用于管理代码段,无需定制开发
最近更新:2026-05-14
研究范围:对完整主题及钩子插件的源码进行全面扫描
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。