So I have the following php:
所以我有以下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 ;
;}
I need to put all the php code above where '.$thisisworking.'
is below. I keep getting semi colon is unexpected php errors when I try.
我需要把所有的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>
Can someone tell me how this can be achieved?
有人能告诉我这是如何实现的吗?
echo EM_Events::Output( array('format'=>
is how the wordpress plugin author, says templates to modify his wordpress plugin should be coded. Can anyone help please?
echo EM_Events :: Output(array('format'=>是wordpress插件的作者,说修改wordpress插件的模板应该编码。有人可以帮忙吗?
UPDATE: I tried this but it doesn't seem to make any difference:
更新:我试过这个,但它似乎没有任何区别:
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>
1 个解决方案
#1
Turn it into a function?
把它变成一个功能?
function foo() {
... your mangled code ...
return $whatever_you_built;
}
$string = "foo bar " . foo() . " baz qux";
#1
Turn it into a function?
把它变成一个功能?
function foo() {
... your mangled code ...
return $whatever_you_built;
}
$string = "foo bar " . foo() . " baz qux";