开发者

php syntax problem. (php in css in php array)

开发者 https://www.devze.com 2023-02-13 05:47 出处:网络
i have short question which is probably super easy to answer but i\'m with stupid today.. can someone please tell me the proper syntax to close the <h4> in my array and explain the correct synt

i have short question which is probably super easy to answer but i'm with stupid today..

can someone please tell me the proper syntax to close the <h4> in my array and explain the correct syntax to me? thanks!

    <?php
        wp_nav_menu(
            array(
                'theme_location' => '1st_menu',
          开发者_运维知识库      'before' => '<h4 '<?php if ( is_page('5')) { echo ' id="visible"'; } ?> >',
                'after' => '</h4>'
            )
        );
    ?>


I guess something like :

    <?php
        wp_nav_menu(
            array(
                'theme_location' => '1st_menu',
                'before' => '<h4 '.(is_page('5') ? ' id="visible"' : '').' >',
                'after' => '</h4>'
            )
        );
    ?>


wp_nav_menu(
    array( 
        'theme_location' => '1st_menu', 
        'before' => '<h4 '. (is_page('5') ? ' id="visible"':'').'>', 
        'after' => '</h4>' 
    ) 
);


don't know about WP but that should be:

<?php
    if(is_page('5')){
        $id = ' id="visible" ';
    }else{
        $id = NULL;
    }
    wp_nav_menu(
        array(
            'theme_location' => '1st_menu',
            'before' => '<h4'.$id.'>',
            'after' => '</h4>'
        )
    );
?>
0

精彩评论

暂无评论...
验证码 换一张
取 消