Forum Replies Created
Viewing 2 posts - 1 through 2 (of 2 total)
-
AuthorPosts
-
webag27
ParticipantGood evening,
I want to share my solution, thank you for your suggestions.
In configuration of plugin, I removed only “{get_values}”, but I leaved correct custom field name.
Than, simply I did populate options thanks to correct hook. In this way I dont need to manipulate results, because they remain alredy correct:add_filter('asp_pre_get_front_filters', 'asp_change_a_filter', 10, 2); function asp_change_a_filter($filters, $type) { foreach ($filters as $k => &$filter) { if ( $filter->type() == 'custom_field' && $filter->field() == 'recensore_aurotore_oblio' ) { $args = array( 'post_type' => 'recensorieautori', 'post_status' => 'publish', 'posts_per_page' => 999, 'orderby' => 'title', 'order' => 'ASC', ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $filter->add(array( 'label' => get_the_title(), 'selected' => false, 'value' => 'a:1:{i:0;s:3:"'. get_the_id() .'";}' )); endwhile; wp_reset_postdata(); } if ( $filter->type() == 'custom_field' && $filter->field() == 'numero_rivista' ) { $args = array( 'post_type' => 'numeridellarivista', 'post_status' => 'publish', 'posts_per_page' => 999, 'orderby' => 'title', 'order' => 'ASC', ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); $filter->add(array( 'label' => get_the_title(), 'selected' => false, 'value' => 'a:1:{i:0;s:2:"'. get_the_id() .'";}' )); endwhile; wp_reset_postdata(); } } return $filters; }webag27
Participantok, that is a big problem for me. Could you indicate me part of code that I could try to edit (edit the function {get_values}) to handle relational fields? Thank you
-
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)