Developer
Using hooks
Hooks in WordPress themes serve as crucial entry points for developers to customize and enhance functionality. While WordPress core provides some action hooks and template tags, they might not cover all necessary use cases. Hooks enable dynamic content and modifications within the theme. Let’s delve into the essential hooks provided by our themes:
This document explains the hooks provided by our themes. Each theme has its own unique prefix for these hooks, such as sasfy_
, agenko_
, or edufit_
. Simply replace the placeholder pixelfit_theme_
with the corresponding theme's prefix when using those hooks.
For example, if you are using the Sasfy WordPress theme, the hooks will be prefixed with sasfy_
instead of pixelfit_theme_
1. HTML <html>
Hook
<html>
HookThis hook is executed before the opening <html>
tag. It allows you to inject content, scripts, or perform actions before the HTML structure of the page starts
2. HTML <head>
Hooks
<head>
HooksThese hooks enable you to insert content at the top (pixelfit_theme_head_start
) or bottom (pixelfit_theme_head_end
) of the section, respectively, allowing you to add custom meta tags, scripts, or styles.
3. HTML <body>
Hooks
<body>
HooksThese hooks allow you to insert content at the beginning (pixelfit_theme_start_body
) or end (pixelfit_theme_end_body
) of the <body>
section, respectively. They are useful for adding custom body elements before or after the main content of the page.
4. Header Hooks
pixelfit_theme_before_header
: Executes before the header section, allowing you to add content or perform actions before the header.pixelfit_theme_header
: Outputs the header content, such as navigation or logo, allowing you to customize or extend the header section.pixelfit_theme_after_header
: Executes after the header section, useful for adding content or performing actions after the header is rendered.
5. Content Hooks
pixelfit_theme_before_content_wrapper
: Executes before the content wrapper starts, allowing you to insert content or perform actions before the main content area.pixelfit_theme_after_content_wrapper
: Executes after the content wrapper ends, useful for adding content or actions after the main content area.pixelfit_theme_start_content_area
: Fired at the beginning of the content area, useful for adding custom elements at the start of the main content.pixelfit_theme_end_content_area
: Fired at the end of the content area, allowing you to insert content or actions after the main content is rendered.pixelfit_theme_before_content
: Fired before the content is displayed, enabling you to add elements or perform actions before the main content.pixelfit_theme_after_content
: Fired after the content is displayed, allowing you to add elements or actions after the main content.
6. Entry Posts Hooks
pixelfit_theme_post_loop
: Fired after the main post loop, allowing you to insert custom content or actions after the posts are displayed.pixelfit_theme_before_article
: Executes before each article, allowing you to insert custom content or perform actions before the article starts.pixelfit_theme_after_article
: Executes after each article, enabling you to add content or perform actions once the article has finished.pixelfit_theme_start_article
: Fired at the beginning of each article, useful for wrapping the article content in custom HTML or elements.pixelfit_theme_end_article
: Fired at the end of each article, useful for closing any custom wrappers around the article content.pixelfit_theme_start_article_summary
: Fired at the start of the article summary section, allowing customization or additional content before the summary.pixelfit_theme_end_article_summary
: Fired at the end of the article summary section, allowing for additional content or actions after the summary.pixelfit_theme_start_article_content
: Fired at the start of the post details/content section, allowing you to add elements before the post content.pixelfit_theme_end_article_content
: Fired at the end of the post details/content section, allowing you to insert custom content or actions after the post content.
7. Page Hooks
pixelfit_theme_page_content
: Fired within the main content area to display the page content. It allows customization or adding specific functionality for the page content itself.pixelfit_theme_start_page_content
: Fired at the beginning of the page content area, allowing you to add custom elements or perform actions before the page content.pixelfit_theme_end_page_content
: Fired at the end of the page content area, allowing you to insert additional content or actions after the page content
8. Sidebar Hooks
pixelfit_theme_before_sidebar
: Fired before the sidebar content is displayed, allowing you to add custom content or perform actions before the sidebar starts.pixelfit_theme_after_sidebar
: Fired after the sidebar content is displayed, enabling you to add content or actions after the sidebar ends.
9. Footer Hooks
pixelfit_theme_before_footer
: Fired before the footer section, allowing you to add custom content or perform actions before the footer starts.pixelfit_theme_footer
: Outputs the footer content, such as footer widgets or copyright information, allowing customization or extension of the footer section.pixelfit_theme_after_footer
: Fired after the footer section, useful for adding content or performing actions after the footer is rendered.
10. Other Hooks
pixelfit_theme_404_content
: Fired on the 404 error page, typically used to display custom content or messages when a page is not found, allowing you to provide a customized error page experience.
Example Usage of Hooks
Example 1: Add a Custom Banner Before the Header
Example 2: Insert a Custom Message After the Footer
Last updated