@boz2006
Where you want to search image block ? If it is default wordpress search you need to add related page title and description ? If you share more details regarding search i can check for you.
Currently I use the default WP search field (extreme top right of my theme). I wanted to have multiple blocks on each page, but each one to be individually searchable. Keywords would be very simple – Beetroot, carrot, coriander….
Maybe there’s a search plugin for more advanced search?
This particular site is purely for private use, and access is blocked by using My. Private Site.
-
This reply was modified 3 years, 8 months ago by
Boz2006. Reason: additional info
-
This reply was modified 3 years, 8 months ago by
Boz2006.
@boz2006
Try adding below code in your theme functions.php file to modify default wordpress search with attachment. Your image name must match search keyword to work.
function attachment_search( $query ) {
if ( $query->is_search ) {
$query->set( 'post_type', array( 'post','page', 'attachment' ) );
$query->set( 'post_status', array( 'publish', 'inherit' ) );
}
return $query;
}
add_filter( 'pre_get_posts', 'attachment_search' );
I hope this will help you!
Many thanks – much appreciated.
One question: What and where is the image name? Surely, if the image had a name, then the default WP search would be OK?
-
This reply was modified 3 years, 8 months ago by
Boz2006.