php facetwp索引一个PODS关系字段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php facetwp索引一个PODS关系字段相关的知识,希望对你有一定的参考价值。

<?php

/** index the post title of a related post field in PODS
 ** $related_post_id could also be used with get_post_meta or other functions to
 ** get info about the related post
 ** be sure to re-index after adding code
 **/
add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'my_facet' == $params['facet_name'] ) { // change my_facet to name of your facet
		$related_post_id = $params['facet_value']['ID']; // depnding on how your relationship field saves its data this might need to be changed or looked up from a different value
		$params['facet_display_value'] = get_the_title( $related_post_id ); // lookup custom field 
		$params['facet_value'] = $params['facet_display_value'];
	}
	return $params;
}, 10, 2 );

以上是关于php facetwp索引一个PODS关系字段的主要内容,如果未能解决你的问题,请参考以下文章

php facetwp索引相关帖子类型中的字段

php facetwp索引相关帖子类型中的字段

php facetwp索引新媒体

php facetwp索引日期

php facetwp索引类及其子类

php facetwp索引只有父母