SearchWP

searchwp\source\post\{$post_type}\parent_attribution\strict

Since: 4.0.6

Table of Contents

Control how Posts without a parent are returned when parent attribution has been enabled.

Parameters

Type Parameter Default Since
Boolean $enabled false 4.0.6

Examples

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:

<?php
// 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' );

How to use this code