Automattic / Automattic/jetpack

[Search] Jetpack search: Customize search

Open
#19,699 0 comments 0 reactions 0 assignees View on GitHub
[Feature] Search [Type] Question
Dominant language
PHP
Stars
1.8k
Forks
898
Avg merge
1d 18h
Merged PRs (30d)
774

Description

Hello,

I need to make a custom query in my search page. But the problem that the search does not go through jetpack

The search page contain 5 sections for 5 post types.

So this is what i did :

I have an array with post types.
```php
$postTypes = ['news' => 6,'events' => 3,'product'=>3,'company' => 3,'press' => 3];
```
And next for each post type i execute this query :

```php
foreach ($postTypes as $postType=>$limit) :
$queryPosts = get_search_posts($postType,$limit);
....
endforeach;
```

This is the function get_search_posts :

```php
function get_search_posts($postType, $limit)
{
$search_query = get_search_query();
$args = array(
'post_type' => $postType,
'post_status' => array('publish'),
'order' => 'DESC',
'orderby' => 'date',
'posts_per_page' => $limit,
's' => $search_query
);
$query = new WP_Query($args);
$all_posts['found_posts'] = $query->found_posts;
$all_posts['max_num_pages'] = $query->max_num_pages;
$all_posts['paged'] = $query->query_vars['paged'];
$all_posts['posts'] = $query->posts;
return $all_posts;
}
```
However, JetPack does not intercept these queries.

My question is: how to get my queries intercepted by JetPack ?

Contributor guide

Open the contributing guide

Research direction

The issue names no Jetpack file or test entry point; start by tracing how Jetpack Search recognizes WordPress queries and compare that path with the custom WP_Query calls shown. Done means identifying the supported integration point or documenting the repository change needed for these queries to be intercepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.