0

So I have the following 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.

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?

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>
12
  • 1
    That last semi-colon looks suspect to me ;} but then I don't do PHP Commented May 11, 2015 at 18:37
  • 2
    @uʍopǝpısdn You would think that would cause an error, but it doesn't. You can have extra semicolons all over the place in PHP and it doesn't do anything. Commented May 11, 2015 at 18:40
  • 1
    @uʍopǝpısdn See: eval.in/348210 Commented May 11, 2015 at 18:43
  • 1
    @Mike Now that's just silly Commented May 11, 2015 at 18:49
  • @uʍopǝpısdn I agree completely. PHP tends to be silly more often than not. Commented May 11, 2015 at 19:02

1 Answer 1

1

Turn it into a function?

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

$string = "foo bar " . foo() . " baz qux";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.