How to get field value of the record where a function is loaded?

How to get the value field of the record on which is loaded a function. In function.php there is code ajax filter records I need to filtered the records by the value of the additional record fields which should automatically happen when you load the functions on this record. Here is the piece of code
add_action('wp_ajax_myfilter', 'misha_filter_function'); // wp_ajax_{ACTION HERE} 
add_action('wp_ajax_nopriv_myfilter', 'misha_filter_function');

misha_filter_function function(){
 if( isset( $_POST['featured_image'] ) && $_POST['featured_image'] == 'on' )

 $keyg = get_post_field('banks');
 $args['meta_query'][] = array(
array(
 'key' => 'Ormskirk',
 'value' => $keyg,
),
array(
 'key' => 'cashback',
 'value' => 'No',
)
);
 $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 ) );


Tributes to the value of the field "banks" - but it does not work. There is another option - get the record id in which is loaded a function and then get the values of its fields here
$keyg = get_post_field('the banks',3948);
 $args['meta_query'][] = array(
array(
 'key' => 'Ormskirk',
 'value' => $keyg,
),
array(
 'key' => 'cashback',
 'value' => 'No',
)
);
 $query = new WP_Query( $args );

= but lack the knowledge to get the record id - I can't break the code from the manuals. Asking for help from knowledgeable ...
April 19th 20 at 12:32
1 answer
April 19th 20 at 12:34
Don't understand what you need.
In a loop can try this:
$keyg = get_post_field( 'the banks', get_the_ID() );
You need to get_the_ID received id of the record which fulfills a function. Now get_the_ID blank value, as it outside the loop - tristian.Ziema commented on April 19th 20 at 12:37
@tristian.Ziema, then describe the task in more detail why you need the field value outside the loop and what are you going to do with it. - Waylon76 commented on April 19th 20 at 12:40
@Waylon76, I need the record id to the filter for a refund on this page https://sovet-bankira.ru/kreditnye-karty-banka-otk... = when you click on "Show" weed out records by the field "Bank", to eventually display the record only owned this Bank. I can insert the Bank's name in the function, but then you have to spawn functions is equal to the count of banks, and it is necessary that the field value is stamped automatically and the Bank will not come - everywhere the filter will display records that belong to this Bank. - tristian.Ziema commented on April 19th 20 at 12:43
@tristian.Ziema, then Ajax peredavat the ID of the post - Waylon76 commented on April 19th 20 at 12:46
@Waylon76, in my situation - how best to implement it ? - tristian.Ziema commented on April 19th 20 at 12:49
@tristian.Ziema, in the js file where you are sending an ajax request add a variable with the id of the post on the analogy featured_image for example. The post ID can be taken from the body class, for example, or to create a data attribute to the html element and take it from there.

Don't know your level of knowledge and what exactly to suggest - Waylon76 commented on April 19th 20 at 12:52
@Waylon76, thank you very much for the tip, already obtained - tristian.Ziema commented on April 19th 20 at 12:55

Find more questions by tags WordPress