wordpress将php编码为html输出

wordpress将php编码为html输出,php,wordpress,return,output,shortcode,Php,Wordpress,Return,Output,Shortcode,我有以下代码: // Add Shortcode Team function team_code() { $output = ""; $output .= "<div id='b-team-all'>"; $output .= "<div class='header-team'>"; $output .= "<span class='b-icon'><i class='fa fa-users' aria- hidden='true'></i&

我有以下代码:

// Add Shortcode Team
function team_code() {
$output = "";
$output .= "<div id='b-team-all'>";
$output .= "<div class='header-team'>";
$output .= "<span class='b-icon'><i class='fa fa-users' aria- hidden='true'></i></span>";
$output .= "<p></p>";
$output .= "<h2>Náš tím</h2>";
$output .= "</div>";
$output .= "<div id='b-full-grid'>";
$output .= "<div id='b-team'>";
$output .= "<?php foreach( get_cfc_meta( 'tim' ) as $key => $value ){ ?>";
$output .= "<div class='b-team-member' style='background-image: url('<?php  the_cfc_field( 'tim','fotka', false, $key ); ?>');'>";
$output .= "<div class='b-team-text'>";
$output .= "<h1><?php the_cfc_field( 'tim','meno', false, $key );  ?></h1>";
$output .= "<divider></divider>";
$output .= "<span><?php the_cfc_field( 'tim','postavenie', false, $key ); ?></span>";
$output .= "</div>";
$output .= "<div class='b-team-overlay'>";
$output .= "</div>";
$output .= "</div>";
$output .= "<?php } ?>";
$output .= "</div>";
$output .= "</div>";
$output .= "</div>";

return $output;

}
add_shortcode( 'team', 'team_code' );
//添加短代码团队
职能团队代码(){
$output=“”;
$output.=“”;
$output.=“”;
$output.=“”;
$output.=“

”; $output.=“Náštím”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; 返回$output; } 添加_短代码(“团队”、“团队代码”);
如何编写正确的php?现在以这种方式获取php不起作用,我在这方面不是很好:)有人能帮忙吗?
谢谢

这是一些看起来很可怕的代码!:-P但是!这是你想要的

例如:

$output .= "<span><?php the_cfc_field( 'tim','postavenie', false, $key ); ?></span>";
这一行:

$output .= "<?php } ?>";
$output.=”;
公正

}

然后它将循环通过,您可以继续添加到
$output

功能团队\u code(){
 function team_code(){
<div id='b-team-all'>
<div class='header-team'>
    <span class='b-icon'><i class='fa fa-users' aria- hidden='true'></i></span>
        <p></p>
    <h2>Náš tím</h2>
</div>
<div id='b-full-grid'>
    <div id='b-team'>
        <?php foreach( get_cfc_meta( 'tim' ) as $key => $value ){ ?>
        <div class='b-team-member' style='background-image: url('<?php  the_cfc_field( 'tim','fotka', false, $key ); ?>');'>
            <div class='b-team-text'>
                <h1><?php the_cfc_field( 'tim','meno', false, $key );  ?></h1>
            <divider></divider>
            <span><?php the_cfc_field( 'tim','postavenie', false, $key ); ?></span>
            </div>
                <div class='b-team-overlay'>
            </div>
        </div>
        <?php } ?>
    </div>
</div>
</div>
}
 add_shortcode('team','team_code');

Náštím } 添加_短代码(“团队”、“团队代码”);

如果你觉得很难解决,为什么要具体化代码?我得到了结果,是我的错:

// Add Shortcode Team
function team_code() {

$output = "";
$output .= "<div id='b-team-all'>";
$output .= "<div class='header-team'>";
$output .= "<span class='b-icon'><i class='fa fa-users' aria- hidden='true'></i></span>";
$output .= "<p></p>";
$output .= "<h2>Náš tím</h2>";
$output .= "</div>";
$output .= "<div id='b-full-grid'>";
$output .= "<div id='b-team'>";
foreach( get_cfc_meta( 'tim' ) as $key => $value ){
    $url_foto = get_cfc_field( 'tim', 'fotka', false, $key );
    $header = get_cfc_field( 'tim','meno', false, $key );
    $position = get_cfc_field( 'tim','postavenie', false, $key );

    $output .= "<div class='b-team-member' style='background-image: url(" . $url_foto['url'] . ")'>";
    $output .= "<div class='b-team-text'>";
    $output .= "<h1>" . $header . "</h1>";
    $output .= "<divider></divider>";
    $output .= "<span>" . $position . "</span>";
    $output .= "</div>";
    $output .= "<div class='b-team-overlay'>";
    $output .= "</div>";
    $output .= "</div>";
    $output .= "</div>";
}
$output .= "</div>";
$output .= "</div>";

return $output;

}
add_shortcode( 'team', 'team_code' );
//添加短代码团队
职能团队代码(){
$output=“”;
$output.=“”;
$output.=“”;
$output.=“”;
$output.=“

”; $output.=“Náštím”; $output.=“”; $output.=“”; $output.=“”; foreach(以$key=>$value的形式获取\u cfc\u meta('tim')){ $url\u foto=get\u cfc\u字段('tim','fotka',false,$key); $header=get_cfc_字段('tim','meno',false,$key); $position=get_cfc_字段('tim','postavenie',false,$key); $output.=“”; $output.=“”; $output.=''.$header.''; $output.=“”; $output.=''.$position.''; $output.=“”; $output.=“”; $output.=“”; $output.=“”; $output.=“”; } $output.=“”; $output.=“”; 返回$output; } 添加_短代码(“团队”、“团队代码”);
您好,谢谢,是的,顺便说一句,这很有效,但是foreach(get_cfc_meta('tim')as$key=>$value)呢{我试过了,但是,在html上循环显示,html保持为空…:/
$output .= "<?php } ?>";
 function team_code(){
<div id='b-team-all'>
<div class='header-team'>
    <span class='b-icon'><i class='fa fa-users' aria- hidden='true'></i></span>
        <p></p>
    <h2>Náš tím</h2>
</div>
<div id='b-full-grid'>
    <div id='b-team'>
        <?php foreach( get_cfc_meta( 'tim' ) as $key => $value ){ ?>
        <div class='b-team-member' style='background-image: url('<?php  the_cfc_field( 'tim','fotka', false, $key ); ?>');'>
            <div class='b-team-text'>
                <h1><?php the_cfc_field( 'tim','meno', false, $key );  ?></h1>
            <divider></divider>
            <span><?php the_cfc_field( 'tim','postavenie', false, $key ); ?></span>
            </div>
                <div class='b-team-overlay'>
            </div>
        </div>
        <?php } ?>
    </div>
</div>
</div>
}
 add_shortcode('team','team_code');
// Add Shortcode Team
function team_code() {

$output = "";
$output .= "<div id='b-team-all'>";
$output .= "<div class='header-team'>";
$output .= "<span class='b-icon'><i class='fa fa-users' aria- hidden='true'></i></span>";
$output .= "<p></p>";
$output .= "<h2>Náš tím</h2>";
$output .= "</div>";
$output .= "<div id='b-full-grid'>";
$output .= "<div id='b-team'>";
foreach( get_cfc_meta( 'tim' ) as $key => $value ){
    $url_foto = get_cfc_field( 'tim', 'fotka', false, $key );
    $header = get_cfc_field( 'tim','meno', false, $key );
    $position = get_cfc_field( 'tim','postavenie', false, $key );

    $output .= "<div class='b-team-member' style='background-image: url(" . $url_foto['url'] . ")'>";
    $output .= "<div class='b-team-text'>";
    $output .= "<h1>" . $header . "</h1>";
    $output .= "<divider></divider>";
    $output .= "<span>" . $position . "</span>";
    $output .= "</div>";
    $output .= "<div class='b-team-overlay'>";
    $output .= "</div>";
    $output .= "</div>";
    $output .= "</div>";
}
$output .= "</div>";
$output .= "</div>";

return $output;

}
add_shortcode( 'team', 'team_code' );