Qualcuno può aiutarmi a query post personalizzati in WordPress? Voglio interrogare più condizioni:
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; ?>
Ho un modello e so che può essere fatto da $args["meta_query"][] = array( with AND & OR relative)
ma forse qualcuno ha una soluzione più semplice?
risposte:
0 per risposta № 1C'è qualche opzione per utilizzare queste condizioni per archiviare le informazioni sui meta della proprietà? Qualcosa come: se condizione true -> proprietà meta = 1
Qualcosa come questo:
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_mdm", true) = 1
<?php endif; ?>
Non so come posso memorizzare queste informazioni per interrogarle?
get_post_meta (get_the_ID (), "nt_mdm", true) = 1 <- questo non funziona
E poi semplice query:
$args["meta_query"][] = array(
"key" => "nt_mdm",
"value" => 1,
"compare" => "IN"
);