Table of Contents
Control how Posts without a parent are returned when parent attribution has been enabled.
All hooks should be added to your custom SearchWP Customizations Plugin.
Drop Media from results that have no parent when parent attribution has been enabled
If you have enabled parent attribution for Media to have SearchWP transfer the weight of Media entries to their parent post (i.e. “Uploaded to”) any relevance weight given to Media will be transferred to its post_parent.
By default, if a Media item does not have a post_parent, the Media entry itself will be returned.
If instead you would prefer that Media without a post_parent are dropped from search results, we can use this hook:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
|// Drop Media from results that have no parent when parent attribution has been enabled in SearchWP.|
|// @link https://searchwp.com/documentation/hooks/searchwp-source-post-post_type-parent_attribution-strict|
|add_filter( 'searchwp\source\post\attachment\parent_attribution\strict', '__return_true' );|