Answer the question
In order to leave comments, you need to log in
How to get the value of the field of the record on which the function is loaded?
How to get the value of the field of the record on which the function is loaded. In function.php there is an ajax record filter code - I need to filter records by the value of an additional record field, which should be automatically obtained when loading the function on this record. Here is a piece of code
add_action('wp_ajax_myfilter', 'misha_filter_function'); // wp_ajax_{ACTION HERE}
add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function');
function misha_filter_function(){
if( isset( $_POST['featured_image'] ) && $_POST['featured_image'] == 'on' )
$keyg = get_post_field('банкс');
$args['meta_query'][] = array(
array(
'key' => 'банкс',
'value' => $keyg,
),
array(
'key' => 'кэшбэк',
'value' => 'Нет',
)
);
$query = new WP_Query( $args );
if( $query->have_posts() ) :
while( $query->have_posts() ): $query->the_post();
$url = wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) );
$keyg = get_post_field('банкс',3948);
$args['meta_query'][] = array(
array(
'key' => 'банкс',
'value' => $keyg,
),
array(
'key' => 'кэшбэк',
'value' => 'Нет',
)
);
$query = new WP_Query( $args );
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question