Zalbi Theme implements various WordPress action hooks that allow developers to extend and customize theme behavior. This page documents all add_action calls used throughout the theme.
Theme Setup Actions
after_setup_theme
The after_setup_theme hook is used multiple times to configure different aspects of the theme during initialization.
zalbi_setup
Hook
string
default: "after_setup_theme"
Fires after the theme is loaded
Callback
function
default: "zalbi_setup"
Main theme setup function
Purpose: Sets up theme defaults and registers support for various WordPress features including:
Theme translation support
Automatic feed links
Title tag support
Post thumbnails
Navigation menus (Primary and Legal Footer)
HTML5 markup
Custom background
Selective refresh for widgets
Custom logo
Source Code:
function zalbi_setup () {
load_theme_textdomain ( 'zalbi' , get_template_directory () . '/languages' );
add_theme_support ( 'automatic-feed-links' );
add_theme_support ( 'title-tag' );
add_theme_support ( 'post-thumbnails' );
register_nav_menus (
array (
'menu-1' => esc_html__ ( 'Primary' , 'zalbi' ),
'menu-legal' => esc_html__ ( 'Menú Legal Footer' , 'zalbi' ),
)
);
add_theme_support (
'html5' ,
array (
'search-form' ,
'comment-form' ,
'comment-list' ,
'gallery' ,
'caption' ,
'style' ,
'script' ,
)
);
add_theme_support (
'custom-background' ,
apply_filters (
'zalbi_custom_background_args' ,
array (
'default-color' => 'ffffff' ,
'default-image' => '' ,
)
)
);
add_theme_support ( 'customize-selective-refresh-widgets' );
add_theme_support (
'custom-logo' ,
array (
'height' => 250 ,
'width' => 250 ,
'flex-width' => true ,
'flex-height' => true ,
)
);
}
add_action ( 'after_setup_theme' , 'zalbi_setup' );
Extension Example:
// Add custom theme support for wide alignment
function my_zalbi_setup_extension () {
add_theme_support ( 'align-wide' );
}
add_action ( 'after_setup_theme' , 'my_zalbi_setup_extension' , 11 );
Use priority higher than 10 to run after the main setup function if you need to extend or modify its behavior.
zalbi_content_width
Hook
string
default: "after_setup_theme"
Fires after the theme is loaded
Callback
function
default: "zalbi_content_width"
Sets the content width in pixels
Runs early, before default priority
Purpose: Sets the global $content_width variable based on the theme’s design and stylesheet. This affects embedded content like videos and images.
Source Code:
function zalbi_content_width () {
$GLOBALS [ 'content_width' ] = apply_filters ( 'zalbi_content_width' , 640 );
}
add_action ( 'after_setup_theme' , 'zalbi_content_width' , 0 );
Extension Example:
// Modify content width
function my_custom_content_width ( $width ) {
return 1200 ; // Increase content width to 1200px
}
add_filter ( 'zalbi_content_width' , 'my_custom_content_width' );
Hook
string
default: "after_setup_theme"
Fires after the theme is loaded
Callback
function
default: "zalbi_custom_header_setup"
Sets up custom header feature
Purpose: Configures WordPress custom header feature with specific dimensions and styling callbacks.
Source Code:
function zalbi_custom_header_setup () {
add_theme_support (
'custom-header' ,
apply_filters (
'zalbi_custom_header_args' ,
array (
'default-image' => '' ,
'default-text-color' => '000000' ,
'width' => 1000 ,
'height' => 250 ,
'flex-height' => true ,
'wp-head-callback' => 'zalbi_header_style' ,
)
)
);
}
add_action ( 'after_setup_theme' , 'zalbi_custom_header_setup' );
zalbi_jetpack_setup
Hook
string
default: "after_setup_theme"
Fires after the theme is loaded
Callback
function
default: "zalbi_jetpack_setup"
Configures Jetpack plugin features
This action only fires if Jetpack is installed and active. The file is conditionally loaded in functions.php:233-235.
Purpose: Adds theme support for Jetpack features including Infinite Scroll, Responsive Videos, and Content Options.
Source Code:
function zalbi_jetpack_setup () {
add_theme_support (
'infinite-scroll' ,
array (
'container' => 'main' ,
'render' => 'zalbi_infinite_scroll_render' ,
'footer' => 'page' ,
)
);
add_theme_support ( 'jetpack-responsive-videos' );
add_theme_support (
'jetpack-content-options' ,
array (
'post-details' => array (
'stylesheet' => 'zalbi-style' ,
'date' => '.posted-on' ,
'categories' => '.cat-links' ,
'tags' => '.tags-links' ,
'author' => '.byline' ,
'comment' => '.comments-link' ,
),
'featured-images' => array (
'archive' => true ,
'post' => true ,
'page' => true ,
),
)
);
}
add_action ( 'after_setup_theme' , 'zalbi_jetpack_setup' );
Hook
string
default: "widgets_init"
Fires when widget areas are registered
Callback
function
default: "zalbi_widgets_init"
Registers theme widget areas
Purpose: Registers a sidebar widget area for the theme.
Source Code:
function zalbi_widgets_init () {
register_sidebar (
array (
'name' => esc_html__ ( 'Sidebar' , 'zalbi' ),
'id' => 'sidebar-1' ,
'description' => esc_html__ ( 'Add widgets here.' , 'zalbi' ),
'before_widget' => '<section id="%1$s" class="widget %2$s">' ,
'after_widget' => '</section>' ,
'before_title' => '<h2 class="widget-title">' ,
'after_title' => '</h2>' ,
)
);
}
add_action ( 'widgets_init' , 'zalbi_widgets_init' );
Extension Example:
// Register additional widget area for footer
function my_footer_widgets () {
register_sidebar (
array (
'name' => 'Footer Widgets' ,
'id' => 'footer-1' ,
'description' => 'Footer widget area' ,
'before_widget' => '<div class="footer-widget">' ,
'after_widget' => '</div>' ,
'before_title' => '<h3>' ,
'after_title' => '</h3>' ,
)
);
}
add_action ( 'widgets_init' , 'my_footer_widgets' );
Scripts & Styles Actions
wp_enqueue_scripts
zalbi_scripts
Hook
string
default: "wp_enqueue_scripts"
Fires when scripts and styles should be enqueued
Callback
function
default: "zalbi_scripts"
Enqueues theme scripts and styles
Purpose: Loads theme stylesheet, navigation JavaScript, Font Awesome icons, Google Fonts, and comment reply script when needed.
Source Code:
function zalbi_scripts () {
wp_enqueue_style ( 'zalbi-style' , get_stylesheet_uri (), array (), _S_VERSION );
wp_style_add_data ( 'zalbi-style' , 'rtl' , 'replace' );
wp_enqueue_script ( 'zalbi-navigation' , get_template_directory_uri () . '/js/navigation.js' , array (), _S_VERSION , true );
// Fonts and Icons
wp_enqueue_style ( 'zalbi-fontawesome' , 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css' );
wp_enqueue_style ( 'zalbi-google-fonts' , 'https://fonts.googleapis.com/css2?family=Nunito:wght@400;700;900&family=Open+Sans:wght@400;600&display=swap' );
if ( is_singular () && comments_open () && get_option ( 'thread_comments' ) ) {
wp_enqueue_script ( 'comment-reply' );
}
}
add_action ( 'wp_enqueue_scripts' , 'zalbi_scripts' );
Extension Example:
// Add custom JavaScript file
function my_custom_scripts () {
wp_enqueue_script ( 'custom-animations' , get_stylesheet_directory_uri () . '/js/animations.js' , array ( 'jquery' ), '1.0' , true );
}
add_action ( 'wp_enqueue_scripts' , 'my_custom_scripts' );
Custom Post Types & Taxonomies
init
zalbi_register_hinchables
Fires after WordPress is fully loaded
Callback
function
default: "zalbi_register_hinchables"
Registers ‘Hinchable’ custom post type
Purpose: Registers the “Hinchable” (Inflatable) custom post type for managing inflatable rental items. This is the core content type for the rental catalog.
Source Code:
function zalbi_register_hinchables () {
$args = array (
'labels' => array (
'name' => 'Hinchables' ,
'singular_name' => 'Hinchable'
),
'public' => true ,
'has_archive' => false ,
'menu_icon' => 'dashicons-smiley' ,
'supports' => array ( 'title' , 'editor' , 'thumbnail' , 'excerpt' ),
'rewrite' => array ( 'slug' => 'catalogo' ),
);
register_post_type ( 'hinchable' , $args );
}
add_action ( 'init' , 'zalbi_register_hinchables' );
Extension Example:
// Add custom fields support to Hinchables
function extend_hinchables_support () {
add_post_type_support ( 'hinchable' , 'custom-fields' );
}
add_action ( 'init' , 'extend_hinchables_support' , 11 );
zalbi_register_taxonomies
Fires after WordPress is fully loaded
Callback
function
default: "zalbi_register_taxonomies"
Registers ‘tipo_hinchable’ taxonomy
Purpose: Registers the “Tipo de Hinchable” (Inflatable Type) taxonomy for categorizing inflatables. This allows filtering and organizing rental items by type.
Source Code:
function zalbi_register_taxonomies () {
register_taxonomy ( 'tipo_hinchable' , 'hinchable' , array (
'labels' => array (
'name' => 'Tipos de Hinchable' ,
'singular_name' => 'Tipo de Hinchable' ,
'menu_name' => 'Tipos de Hinchable' ,
),
'public' => true ,
'hierarchical' => true ,
'show_ui' => true ,
'show_admin_column' => true ,
'show_in_rest' => true ,
'rewrite' => array ( 'slug' => 'tipo' ),
) );
}
add_action ( 'init' , 'zalbi_register_taxonomies' );
Extension Example:
// Add additional taxonomy for size classification
function add_size_taxonomy () {
register_taxonomy ( 'tamano_hinchable' , 'hinchable' , array (
'labels' => array (
'name' => 'Tamaños' ,
'singular_name' => 'Tamaño' ,
),
'hierarchical' => true ,
'show_in_rest' => true ,
'rewrite' => array ( 'slug' => 'tamano' ),
) );
}
add_action ( 'init' , 'add_size_taxonomy' );
zalbi_register_eventos
Fires after WordPress is fully loaded
Callback
function
default: "zalbi_register_eventos"
Registers ‘Evento’ custom post type
Purpose: Registers the “Evento” (Event) custom post type for managing event content and showcasing event services.
Source Code:
function zalbi_register_eventos () {
$args = array (
'labels' => array (
'name' => 'Eventos' ,
'singular_name' => 'Evento'
),
'public' => true ,
'has_archive' => false ,
'menu_icon' => 'dashicons-calendar-alt' ,
'supports' => array ( 'title' , 'editor' , 'thumbnail' , 'excerpt' ),
'rewrite' => array ( 'slug' => 'eventos' ),
);
register_post_type ( 'evento' , $args );
}
add_action ( 'init' , 'zalbi_register_eventos' );
Theme Customizer Actions
customize_register
zalbi_customize_whatsapp
Hook
string
default: "customize_register"
Fires when the Customizer registers controls
Callback
function
default: "zalbi_customize_whatsapp"
Adds WhatsApp button customizer settings
Purpose: Adds a customizer section and control for configuring the floating WhatsApp button phone number.
Source Code:
function zalbi_customize_whatsapp ( $wp_customize ) {
$wp_customize -> add_section ( 'zalbi_whatsapp_section' , array (
'title' => __ ( 'Botón WhatsApp' , 'zalbi' ),
'description' => __ ( 'Configura aquí el número del botón flotante.' , 'zalbi' ),
'priority' => 120 ,
));
$wp_customize -> add_setting ( 'zalbi_whatsapp_number' , array (
'default' => '' ,
'transport' => 'refresh' ,
'sanitize_callback' => 'sanitize_text_field' ,
));
$wp_customize -> add_control ( 'zalbi_whatsapp_number' , array (
'label' => __ ( 'Número de teléfono' , 'zalbi' ),
'section' => 'zalbi_whatsapp_section' ,
'type' => 'text' ,
'description' => 'Escribe el número con prefijo (ej: 34658887358). Si lo dejas vacío, el botón desaparece.' ,
));
}
add_action ( 'customize_register' , 'zalbi_customize_whatsapp' );
Extension Example:
// Add WhatsApp message customization
function extend_whatsapp_customizer ( $wp_customize ) {
$wp_customize -> add_setting ( 'zalbi_whatsapp_message' , array (
'default' => 'Hola, me interesa obtener información' ,
'sanitize_callback' => 'sanitize_text_field' ,
));
$wp_customize -> add_control ( 'zalbi_whatsapp_message' , array (
'label' => 'Mensaje predeterminado' ,
'section' => 'zalbi_whatsapp_section' ,
'type' => 'textarea' ,
));
}
add_action ( 'customize_register' , 'extend_whatsapp_customizer' );
zalbi_customize_register
Hook
string
default: "customize_register"
Fires when the Customizer registers controls
Callback
function
default: "zalbi_customize_register"
Configures customizer preview settings
Purpose: Enables postMessage transport for live preview of site title, description, and header text color. Also sets up selective refresh partials.
Source Code:
function zalbi_customize_register ( $wp_customize ) {
$wp_customize -> get_setting ( 'blogname' ) -> transport = 'postMessage' ;
$wp_customize -> get_setting ( 'blogdescription' ) -> transport = 'postMessage' ;
$wp_customize -> get_setting ( 'header_textcolor' ) -> transport = 'postMessage' ;
if ( isset ( $wp_customize -> selective_refresh ) ) {
$wp_customize -> selective_refresh -> add_partial (
'blogname' ,
array (
'selector' => '.site-title a' ,
'render_callback' => 'zalbi_customize_partial_blogname' ,
)
);
$wp_customize -> selective_refresh -> add_partial (
'blogdescription' ,
array (
'selector' => '.site-description' ,
'render_callback' => 'zalbi_customize_partial_blogdescription' ,
)
);
}
}
add_action ( 'customize_register' , 'zalbi_customize_register' );
customize_preview_init
zalbi_customize_preview_js
Hook
string
default: "customize_preview_init"
Fires in the Customizer preview iframe
Callback
function
default: "zalbi_customize_preview_js"
Enqueues customizer preview JavaScript
Purpose: Loads JavaScript for live preview updates in the Theme Customizer.
Source Code:
function zalbi_customize_preview_js () {
wp_enqueue_script ( 'zalbi-customizer' , get_template_directory_uri () . '/js/customizer.js' , array ( 'customize-preview' ), _S_VERSION , true );
}
add_action ( 'customize_preview_init' , 'zalbi_customize_preview_js' );
wp_head
Fires in the head section of the HTML document
Callback
function
default: "zalbi_pingback_header"
Adds pingback URL for discovery
inc/template-functions.php:37
Purpose: Adds a pingback URL auto-discovery header for single posts, pages, or attachments when pings are enabled.
Source Code:
inc/template-functions.php
function zalbi_pingback_header () {
if ( is_singular () && pings_open () ) {
printf ( '<link rel="pingback" href="%s">' , esc_url ( get_bloginfo ( 'pingback_url' ) ) );
}
}
add_action ( 'wp_head' , 'zalbi_pingback_header' );
Body Actions
wp_body_open
Hook
string
default: "wp_body_open"
Fires immediately after the opening body tag
inc/template-tags.php:163
Purpose: Provides a hook point for plugins and child themes to inject content immediately after the <body> tag opens. This is a backward compatibility shim for WordPress versions older than 5.2.
Source Code:
if ( ! function_exists ( 'wp_body_open' ) ) :
function wp_body_open () {
do_action ( 'wp_body_open' );
}
endif ;
WordPress 5.2+ includes this function natively. The theme provides a fallback for older versions.
Extension Example:
// Add Google Tag Manager after body tag
function add_gtm_body () {
echo '<!-- Google Tag Manager (noscript) -->' ;
echo '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-XXXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>' ;
}
add_action ( 'wp_body_open' , 'add_gtm_body' );
Action Reference Table
Hook Callback Priority File Purpose after_setup_themezalbi_setup10 functions.php:90 Main theme setup after_setup_themezalbi_content_width0 functions.php:98 Set content width after_setup_themezalbi_custom_header_setup10 custom-header.php:35 Custom header config after_setup_themezalbi_jetpack_setup10 jetpack.php:51 Jetpack integration widgets_initzalbi_widgets_init10 functions.php:116 Register sidebars wp_enqueue_scriptszalbi_scripts10 functions.php:135 Enqueue assets initzalbi_register_hinchables10 functions.php:150 Register CPT initzalbi_register_taxonomies10 functions.php:168 Register taxonomy initzalbi_register_eventos10 functions.php:183 Register CPT customize_registerzalbi_customize_whatsapp10 functions.php:208 WhatsApp settings customize_registerzalbi_customize_register10 customizer.php:35 Customizer config customize_preview_initzalbi_customize_preview_js10 customizer.php:61 Preview JS wp_headzalbi_pingback_header10 template-functions.php:37 Pingback header wp_body_openN/A N/A template-tags.php:163 Action hook point