in using GeneratePress Theme construction WordPress At the time of the website, the Block Element and Hook The system provides powerful page insertion capabilities. Many users will insert customized modules, such as prompt boxes, advertisements, author information, etc., under the title of the article, at the end of the content or in the sidebar. The display order of these modules depends on the "Hook Priority".
In this article, we will illustrate how Hook Priority works and how to set it up by way of a practical demonstration.
![Image [1] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517114004574-image.png)
i. The default priority is 10
When you create a Block ElementThe system defaults to 10 if no priority is set when a Hook is inserted into a page.
For example. generate_after_header
In these two Hooks, content blocks are added:
- The first is the blue background container (default priority 10)
![Image [2] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517140454371-image.png)
- The second is the pink background container (also default priority 10)
![Image [3] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517140555303-image.png)
Because the priority is the same, the system displays them in the order they were created. That is, the blue container created first comes first and the pink container comes second.
![Image [4] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517140617162-image.png)
II. Changing the display order by modifying the priority
You can manually set the priority value to control the order of the elements:
- Set the priority of the blue container to 12
![Image [5] - How to Control the Display Order of Page Elements in GeneratePress Using Hook Prioritization](http://gqxi.cn/wp-content/uploads/2025/05/20250517140703561-image.png)
- The pink container stays at the default 10
After refreshing the page, the blue container will be displayed after the pink container.
![Image [6] - How to Control the Display Order of Page Elements in GeneratePress Using Hook Prioritization](http://gqxi.cn/wp-content/uploads/2025/05/20250517140810583-image.png)
The conclusion is that the smaller the value the higher the priority, the further forward the element is. The larger the value the higher the priority, the further back the element goes.
III. Inserting subheadings between article titles and meta-information
This is a very common scenario: one wishes to insert a subheading or descriptive content to be displayed in the articlecaptionand between meta-information such as release date.
Default:
- The title of the article uses the
H1
tab (of a window) (computing) - Meta-information (e.g., author, date) is also passed through the Hook Insert, priority 10
- If you create a subtitle block that also uses the
generate_after_entry_title
If the priority is 10, then it comes after the meta-message
![Image [7] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517141052723-image.png)
Solution:
- Set subheading priority to 7 (less than 10)
![Image [8] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517141121719-image.png)
- This way the subtitle is displayed between the title and the meta information
![Image [9] - How to Control the Display Order of Page Elements in GeneratePress Using Hook Prioritization](http://gqxi.cn/wp-content/uploads/2025/05/20250517141147687-image.png)
If you set the priority to 11, the subtitle appears after the meta information.
![Image [10] - How to Control the Display Order of Page Elements in GeneratePress Using Hook Prioritization](http://gqxi.cn/wp-content/uploads/2025/05/20250517141212757-image.png)
![Image [11] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517141308191-image.png)
IV. Controlling the order in which content blocks are displayed at the end of an article
Many sites will add modules at the end of articles such as:
- Author Information
- Related Articles
- advertisements or CTA blocs
![Image [12] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517141644313-image.png)
These modules are usually inserted in the generate_after_entry_content
in this Hook, and the footer meta information (Footer Meta) also uses this Hook with priority 10.
![Image [13] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517141707125-image.png)
If you want the custom module to appear above the footer meta:
- Set the priority of this module to 9
![Image [14] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517141729374-image.png)
This allows you to adjust their top and bottom order without changing the HTML Structure or writing CSSThe
![Image [15] - How to Control the Display Order of Page Elements Using Hook Prioritization in GeneratePress](http://gqxi.cn/wp-content/uploads/2025/05/20250517141811684-image.png)
summarize
Hook priority is GeneratePress One of the important mechanisms for controlling the structure of a page:
- The default priority is 10
- The smaller the priority value, the more content is displayed first
- If multiple elements use the same Hook and have the same priority, they are listed in the order they were created.
- Flexibility to insert advertisements, subheadings, explanatory text, etc. without code modifications
Proficiency in the way Hook and Priority are combined helps to better customize the page content layout and achieve a well-structured presentation.
Recent Updates
Link to this article:http://gqxi.cn/en/54952The article is copyrighted and must be reproduced with attribution.
No comments