filter custom field with checkboxes and show it with one shortcode

I have a custom field with checkboxes. I created a code to show post-typs filtered by checkbox value with shortcodes e.g

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 0
Add a comment  | 

1 Answer 1

Reset to default 0
add_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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745592822a4634932.html

相关推荐

  • filter custom field with checkboxes and show it with one shortcode

    I have a custom field with checkboxes. I created a code to show post-typs filtered by checkbox value with shortcodes e.g

    15小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信