php facetwp WPJM字段编辑器复选框

Posted

tags:

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

<?php

/** set your facet to use the Post Type as the datasource, this is just a placeholder to make sure it is being indexed
 ** the filter will then check and index the value of the post meta
 ** 'job_check' is the facet name change as needed
 ** '_job_check' is the custom meta key name, make sure you are checking the correct meta key
 **/


add_filter( 'facetwp_index_row', function( $params, $class ) {
	if ( 'job_check' == $params['facet_name'] && 'job_listing' == get_post_type( $params['post_id'] ) ) {
		if ( '1' === get_post_meta( $params['post_id'], '_job_check', true ) ) {
			$params['facet_value'] = '1';
			$params['facet_display_value'] = 'Yes';
		} else {
			$params['facet_value'] = '0';
			$params['facet_display_value'] = 'No';
		}
	} else {
		return false;
	}
	return $params;
}, 10, 2);

以上是关于php facetwp WPJM字段编辑器复选框的主要内容,如果未能解决你的问题,请参考以下文章

php facetwp index复选框保存为数组

php facetwp index复选框保存为数组

php facetwp将扩展类添加到复选框

php facetwp将扩展类添加到复选框

php facetwp将span添加到复选框标签

php facetwp index指示设置字段而不是字段的值