簡體   English   中英

我怎樣才能把這個PHP到這個HTML?

[英]How can I put this php into this html?

所以我有以下PHP:

    $latest_cpt = get_posts("post_type=event&numberposts=1"); 
$theidone =$latest_cpt[0]->ID;
$this_post_id =  $theidone; //get_the_ID();
$key_2_value =  get_post_meta( $this_post_id, 'custom_select', true );
if( ! empty( $key_2_value )) {
$thisisworking =   $key_2_value ;
 ;}

我需要將所有的php代碼放在'.$thisisworking.' 在下面。 我嘗試時不斷出現半冒號是意料之外的php錯誤。

div id="indent">
 <span style="font-size:0.2em">
    <h2><?php echo $EM_Category->output('#_CATEGORYNAME'); ?></h2>
    </span>
    <?php echo $EM_Category->output('#_CATEGORYNOTES'); ?></p>
    <p> <?php //echo $EM_Category->output('#_CATEGORYALLEVENTS'); ?>  </p>


    <?php echo EM_Events::Output( array('format'=>
'
<li>
<br />
<span style="color: #ed834e; clear:both;  display:block"> '.$thisisworking.'#_EVENTNAME </span> 
 </li>
<br />
<b> 
<li>

有人可以告訴我如何實現嗎?

echo EM_Events::Output( array('format'=>是wordpress插件的作者,說修改他的wordpress插件的模板應該被編碼。有人可以幫忙嗎?

更新:我嘗試過此操作,但似乎沒有任何區別:

function letsmakethiswork()  { 
    $latest_cpt = get_posts("post_type=event"); 
    foreach ( $latest_cpt as $cpt_post ) {
        $theidone =$cpt_post->ID;
        $this_post_id =  $theidone; //get_the_ID();
        $key_2_value =  get_post_meta( $this_post_id, 'custom_select', true );
        if( ! empty( $key_2_value )) {
            $thisisworking =   $key_2_value ;
        }
        return $key_2_value;
    }
}
    // END OF NEW CATEGORY SYSTEM 
?>

<div id="indent">
 <span style="font-size:0.2em">
    <h2><?php echo $EM_Category->output('#_CATEGORYNAME'); ?></h2>
    </span>
    <?php echo $EM_Category->output('#_CATEGORYNOTES'); ?></p>
    <p> <?php //echo $EM_Category->output('#_CATEGORYALLEVENTS'); ?>  </p>


    <?php echo EM_Events::Output( array('format'=>
'
<li>
<br />
<span style="color: #ed834e; clear:both;  display:block"> '.letsmakethiswork().'#_EVENTNAME </span> 
 </li>
<br />
<b> 
<li>

變成一個功能?

function foo() { 
   ... your mangled code ...
   return $whatever_you_built;
}

$string = "foo bar " . foo() . " baz qux";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM