0

现在我添加了 css,PHP 不会显示的这段代码有什么问题?

$args = array(       
'meta_key' => 'anniversary_date',     
 'meta_value' => 0,   
 );    
$user_query = new WP_User_Query( $args );   
 $users = $user_query->get_results();    

 foreach( $users as $user ):      
echo "<div class=\"anniversary-output\">"$user->display_name"</div>";    
 echo "<div class=\"anniversary-output\">will be celebrating their anniversary on </div>";       
echo "<div class=\"anniversary-output\">" get_user_meta( $user->ID, 'anniversary_date', true )"</div>";     
 endforeach;   
4

3 回答 3

1
<?php
$args = array(
    'meta_key' => 'anniversary_date',     
    'meta_value' => 0  
);

$user_query = new WP_User_Query( $args );   
$users = $user_query->get_results();    

foreach( $users as $user ) {
    echo '<div class="anniversary-output">'.$user->display_name.'</div>';
    echo '<div class="anniversary-output">will be celebrating their anniversary on</div>';       
    echo '<div class="anniversary-output">'.get_user_meta($user->ID,'anniversary_date',true).'</div>';     
}
于 2012-05-31T13:32:53.970 回答
0

您的 php 中有几个错误:

数组中的额外逗号 & 没有 concat.

<?php 
$args = array(       
'meta_key' => 'anniversary_date',     
'meta_value' => 0);    
$user_query = new WP_User_Query( $args );   
$users = $user_query->get_results();    

 foreach( $users as $user ):      
   echo "<div class=\"anniversary-output\">".$user->display_name."</div>";    
   echo "<div class=\"anniversary-output\">will be celebrating their anniversary on </div>";       
   echo "<div class=\"anniversary-output\">".get_user_meta( $user->ID, 'anniversary_date', true )."</div>";     
 endforeach; 
?>
于 2012-05-31T13:32:27.053 回答
0

我添加了串联。试试这个

echo "<div class=\"anniversary-output\">".$user->display_name."</div>";    
echo "<div class=\"anniversary-output\">will be celebrating their anniversary on </div>";       
echo "<div class=\"anniversary-output\">".get_user_meta( $user->ID, 'anniversary_date', true )."</div>";
于 2012-05-31T13:33:10.113 回答