Hi Brian,
If you want to create a search by custom field and display results (posts), follow this documentation, field1
is the ID of the field or column key in the custom table, in the example of the document it would be address
or phone
or email
and the value1
is the input value of search form.
The code gets post by the custom field which is stored in the custom table should be
global $wpdb;
$ids = $wpdb->get_col( "SELECT ID FROM my_custom_table WHERE address = 'input-search-value'" );
if ( empty( $ids ) ) {
echo 'There is no posts';
} else {
$query = new WP_Query( [
'post_type' => 'post',
'post__in' => $ids,
] );
// Do something
while ( $query->have_posts() ) {
$query->the_post();
echo '<a href="'.get_the_permalink().'">'.get_the_title().'</a><br>';
}
wp_reset_postdata();
}