1
任何人都可以幫助我在WordPress中查詢自定義帖子嗎? 我要查詢多個條件:由多個條件查詢WordPress的自定義帖子
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; ?>
我有模板,並知道它可以通過$args['meta_query'][] = array(with AND & OR relative)
做,但也許有人有簡單的解決方案?
'meta_query'是您最好的選擇在這裏,和大概只有選項,除非你想運行一個自己不應該做的自定義SQL查詢 –