我正在使用 pods 管理插件,我想更改数组中的值。 raspored.meta_value 是从 0-6 或从周日到周一的天数。
我希望 raspored.meta_value = "dynamic"中的值正在改变日子的方式。
顺便说一句:我是新来的,英语不是很好。希望你能理解:)
$params = array( 'limit' => -1, 'where' => 'raspored.meta_value = "4"' );
$pods = pods( 'raspored', $params );
if ( $pods->total() > 0 ) {
while( $pods->fetch() ) {
//reset id
$pods->id = $pods->id();
//get the template
$temp = $pods->template( 'Probni' );
//output template if it exists
if ( isset( $temp ) ) {
echo $pods->display( 'some_other_field' );
echo $temp;
}
}
//pagination
echo $pods->pagination();
}
else {
echo 'No content found.';
}
最佳答案
我找到了解决方案。 我添加了 if 语句并更改了“where 子句”的数组值。
例子:
$params = array( 'limit' => -1, 'where' => 'raspored.meta_value = "1"', 'orderby' => 'vrijeme_start ASC' );
if (date("l") === "Monday") {
$params["where"] = array ('1');
}
elseif (date("l") === "Tuesday") {
$params["where"] = array ('2');
}
elseif (date("l") === "Wednesday") {
$params["where"] = array ('3');
}
elseif (date("l") === "Thursday") {
$params["where"] = array ('4');
}
elseif (date("l") === "Friday") {
$params["where"] = array ('5');
}
elseif (date("l") === "Saturday") {
$params["where"] = array ('6');
}
elseif (date("l") === "Sunday") {
$params["where"] = array ('0');
}
else {
echo 'Nema sadržaja';
}
希望有人会需要这个:)
关于php - 如何在 php 中使 Pods 管理数组值动态化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52643772/