php facetwp索引关系

Posted

tags:

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

<?php

/** make the datasource something you know will always have a value for every post - like post title - it
 ** is only a placeholder and won't be indexed 
 **/

add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'search_new' == $params['facet_name'] ) { // change my_facet to name of your facet
		
		$project_id = $params['post_id'];
		
		/** some code here to make an array of post ids of
		    people posts that are associated with the project **/
		
		// loop of array of people post ids you have created above
		foreach ( $people_posts as $people ) {
			// Update the values to be inserted into database.
			$people_title = get_the_title( $people );
			$people_params = $params;
			$people_params['facet_value'] = $people_title;
			$people_params['facet_display_value'] = $people_title;
			// Insert each value to the database.
			$class->insert( $people_params );
		}
		
		return false; // we won't index the original value
	}
	return $params;
}, 10, 2 );

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

php facetwp索引新媒体

php facetwp索引日期

php facetwp索引类及其子类

php facetwp索引只有父母

php facetwp索引父母

php facetwp索引文件扩展名