admin管理员组文章数量:1023758
I have a custom field with checkboxes. I created a code to show post-typs filtered by checkbox value with shortcodes e.g. [bettenaert-Querbett]
. The code works but do not look nice.
if ($i = 'Querbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Alkovenbett' ) {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Queensbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Hubbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
Is there any way to make the value variable, to have only one if-function or can I do it in an other way? Has anyone an idea and can help me?
I have a custom field with checkboxes. I created a code to show post-typs filtered by checkbox value with shortcodes e.g. [bettenaert-Querbett]
. The code works but do not look nice.
if ($i = 'Querbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Alkovenbett' ) {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Queensbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Hubbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
Is there any way to make the value variable, to have only one if-function or can I do it in an other way? Has anyone an idea and can help me?
Share Improve this question edited Apr 13, 2019 at 18:12 Qaisar Feroz 2,1471 gold badge9 silver badges20 bronze badges asked Apr 13, 2019 at 13:22 kuh13kuh13 51 bronze badge 01 Answer
Reset to default 0add_shortcode( "Querbett", "bettenaert");
add_shortcode( "Alkovenbett", "bettenaert");
add_shortcode( "Queensbett", "bettenaert");
add_shortcode( "Hubbett", "bettenaert");
function bettenaert ( $atts, $content = null, $tag ) {
modell_nach_bettenart_2( $tag );
}
Now use shortcode [Querbett]
, [Alkovenbett]
, [Queensbett]
or[Hubbett]
as required.
I hope this may help.
I have a custom field with checkboxes. I created a code to show post-typs filtered by checkbox value with shortcodes e.g. [bettenaert-Querbett]
. The code works but do not look nice.
if ($i = 'Querbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Alkovenbett' ) {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Queensbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Hubbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
Is there any way to make the value variable, to have only one if-function or can I do it in an other way? Has anyone an idea and can help me?
I have a custom field with checkboxes. I created a code to show post-typs filtered by checkbox value with shortcodes e.g. [bettenaert-Querbett]
. The code works but do not look nice.
if ($i = 'Querbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Alkovenbett' ) {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Queensbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
if ( $i = 'Hubbett') {
add_shortcode( "bettenaert-{$i}", function() use ( $i ) {
modell_nach_bettenart_2( $i );
} );
}
Is there any way to make the value variable, to have only one if-function or can I do it in an other way? Has anyone an idea and can help me?
Share Improve this question edited Apr 13, 2019 at 18:12 Qaisar Feroz 2,1471 gold badge9 silver badges20 bronze badges asked Apr 13, 2019 at 13:22 kuh13kuh13 51 bronze badge 01 Answer
Reset to default 0add_shortcode( "Querbett", "bettenaert");
add_shortcode( "Alkovenbett", "bettenaert");
add_shortcode( "Queensbett", "bettenaert");
add_shortcode( "Hubbett", "bettenaert");
function bettenaert ( $atts, $content = null, $tag ) {
modell_nach_bettenart_2( $tag );
}
Now use shortcode [Querbett]
, [Alkovenbett]
, [Queensbett]
or[Hubbett]
as required.
I hope this may help.
本文标签: filter custom field with checkboxes and show it with one shortcode
版权声明:本文标题:filter custom field with checkboxes and show it with one shortcode 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745592820a2157987.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论