AP_QA_Query_Hooks::modify_main_posts( array $posts, object $query )

Description #

Modify main query.

Parameters #

  • $posts
    array (Required) Array of post object.
  • $query
    object (Required) Wp_Query object.

Changelog #

VersionDescription
4.1.0Introduced.

Source #

File: includes/qaquery-hooks.php

	public static function modify_main_posts( $posts, $query ) {
		if ( ! is_admin() && $query->is_main_query() && $query->is_search() && 'question' === get_query_var( 'post_type' ) ) {
			$query->found_posts   = 1;
			$query->max_num_pages = 1;
			$posts                = array( get_post( ap_opt( 'base_page' ) ) );
		}

		return $posts;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment