public function init_page( int $pid, bool $standalone )
This method is intended to be used when building layouts directly inside theme template files, as opposed to building layout components in the theme layout class' build_components() method and setting the component order in determine_attributes().
This method sets up the layout class similiar to how the build_page() method does, but with a few key differences:
- init_page() does not call the determine_attributes() method. Insteaded, minimal attributes are set.
- init_page() does not call the build_layout() method, as it is assumed that you will be building the layout manually. That being said, reusable components can still be build by using the build_component() method.
- init_page() does set $attr["is_front"] to true if the post ID passed to the method is the ID of the front page.
- init_page() does query and store post meta and theme options in the $meta and $opts properties.
- init_page() can only be used for single post templates (not archives)
(int) (required) The post ID that you would like to load data for
(bool) (optional) By default, the build_component(), get_header_markup(), and get_footer_markup() methods will only return markup from $this->html. Any added scripts or modals will be returned with get_footer_markup() when it is called. If you do no intend to call get_footer_markup(), pass the $standalone argument for init_page() as true. When set to true, build_component(), get_header_markup(), and get_footer_markup() will return merged output containing the contents of $this->html, $this->scripts, and $this->modals, resetting the contents of each every time one of the methods is called.
Below is an example of a page template built using init_page():