Can anybody help me query custom post in WordPress?
I want to query multiple conditions:
if(get_post_meta(get_the_ID(), 'nt_status', true) == "for-sale" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "85" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "4847.40" && has_term( 'mieszkanie', 'propertytype' ) && has_term( 'poznan', 'location' )) :?>
return true
<?php endif; ?>
<?php if(get_post_meta(get_the_ID(), 'nt_status', true) == "for-sale" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "85" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "4126.68" && has_term( 'mieszkanie', 'propertytype' ) && has_term( 'powiat-poznanski', 'location' )) :?>
return true
<?php endif; ?>
<?php if(get_post_meta(get_the_ID(), 'nt_status', true) == "for-sale" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "110" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "4847.40" && has_term( 'dom', 'propertytype' ) && has_term( 'poznan', 'location' )) :?>
return true
<?php endif; ?>
<?php if(get_post_meta(get_the_ID(), 'nt_status', true) == "for-sale" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "110" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "4126.68" && has_term( 'mieszkanie', 'propertytype' ) && has_term( 'powiat-poznanski', 'location' )) :?>
return true
<?php endif; ?>
<?php if(get_post_meta(get_the_ID(), 'nt_status', true) == "pierwotny" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "85" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "5924,60" && has_term( 'mieszkanie', 'propertytype' ) && has_term( 'poznan', 'location' )) :?>
return true
<?php endif; ?>
<?php if(get_post_meta(get_the_ID(), 'nt_status', true) == "pierwotny" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "85" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "5043,72" && has_term( 'mieszkanie', 'propertytype' ) && has_term( 'powiat-poznanski', 'location' )) :?>
return true
<?php endif; ?>
<?php if(get_post_meta(get_the_ID(), 'nt_status', true) == "pierwotny" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "110" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "5924,60" && has_term( 'dom', 'propertytype' ) && has_term( 'poznan', 'location' )) :?>
return true
<?php endif; ?>
<?php if(get_post_meta(get_the_ID(), 'nt_status', true) == "pierwotny" && get_post_meta($post->ID, "nt_wlasnosc", true)!= "udziaÅ" && get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "110" && get_post_meta(get_the_ID(), 'nt_listprice', true)/get_post_meta(get_the_ID(), 'nt_plot_size', true) <= "5043,72" && has_term( 'dom', 'propertytype' ) && has_term( 'powiat-poznanski', 'location' )) :?>
return true
<?php endif; ?>
I have template and know that it can be done by $args['meta_query'][] = array( with AND & OR relative)
but maybe someone have simpler solution?
Is there any option to use this conditions to store to property meta information? Something like: if condition true -> property meta = 1
Something like this:
I don’t know how can I store this info to query?
get_post_meta(get_the_ID(), ‘nt_mdm’, true) = 1 <- this doesn’t work
And then simple query: