Yoast\WP\SEO\Wrappers
WP_Query_Wrapper{}
Wrapper for WP_Query.
Хуков нет.
Использование
$WP_Query_Wrapper = new WP_Query_Wrapper(); // use class methods
Методы
- public get_main_query()
- public get_query()
- public reset_query()
- public set_query( WP_Query $wp_query )
Код WP_Query_Wrapper{} WP Query Wrapper{} Yoast 22.4
class WP_Query_Wrapper { /** * Returns the global WP_Query object. * * @return WP_Query The WP_Query object. */ public function get_query() { return $GLOBALS['wp_query']; } /** * Returns the global main WP_Query object. * * @return WP_Query The WP_Query object. */ public function get_main_query() { return $GLOBALS['wp_the_query']; } /** * Sets the global WP_Query object. * * @param WP_Query $wp_query The WP Query. * * @return void */ public function set_query( WP_Query $wp_query ) { // phpcs:ignore WordPress.WP.GlobalVariablesOverride -- This is a deliberate action. $GLOBALS['wp_query'] = $wp_query; } /** * Resets the global WP_Query object. * * @return void */ public function reset_query() { \wp_reset_query(); } }