WordPress action when main page/post is loaded

The the_post action is called whenever a post is displayed. What action is the best to use when the main page/post loads?

Thanks

Related posts

1 comment

  1. There is no specific action for the main page but depending on your needs you can hook the_post and call the function is_home or is_front_page to determine if the main page is currently being viewed.

    Available actions are listed here. Depending on what you want to do with the main page and when, you can hook the_post, or possible wp, wp_head, get_header to run the check for the main page and run your code if that condition is met.

Comments are closed.