下面的代码不带格式打印到一个块中。鉴于短代码已经运行 php,我是否正确指定了 html?感觉不太像,因为 HTML 部分似乎不适合我。它只是作为整个块输出。(见图)
function trying_2() {
'
<table border="1">
<tr>
<th>name</th>
<th>partysize</th>
<th>phonenumber</th>
</tr>';
global $wpdb;
// sending query
$result = $wpdb->get_results ("SELECT * FROM table_name");
foreach ( $result as $print ) {
echo '<tr>';
echo '<td>' . $print->name.'</td>';
echo '<td>' . $print->partysize.'</td>';
echo '<td>' . $print->phonenumber.'</td>';
echo '<td>' . $print->emailaddress.'</td>';
echo '<td>' . $print->Time_stamp.'</td>';
echo '<td>' . $print->currentstatus.'</td>';
'</tr>';
}
'</table>';
}
add_shortcode('tryin', 'trying_2');
九州编程