我在functions.php
文件上創建了一個函數,該函數從數據庫中的表中檢索數據,並將其放置在HTML
中。style.php內的html表格wordpress
我的問題是,我需要這個樣式表,它的行和列,以設置頁邊距,填充等
這是我到目前爲止有:
add_shortcode('persona-table', 'persona_table_shortcode');
// this function generates the shortcode output
function persona_table_shortcode($args) {
global $wpdb;
// Shortcodes RETURN content, so store in a variable to return
$content = '<table class="tabledatos">';
$content .= '<tr><th>Firstname</th><th>Lastname</th><th>Points</th></tr>';
$results = $wpdb->get_results('SELECT * FROM persona');
foreach ($results AS $row) {
$content = '<tr>';
// Modify these to match the database structure
$content .= '<td class=rowtable>' . $row->ID_per . '</td>';
$content .= '<td class=rowtable>' . $row->nombre . '</td>';
$content .= '<td class=rowtable>' . $row->apellido . '</td>';
$content .= '<td class=rowtable>' . $row->documento . '</td>';
$content .= '<td class=rowtable>' . $row->tel. '</td>';
$content .= '<tr>';
}
$content .= '</table>';
// return the table
return $content;
}
由於你可以看到每個<td>
我已經添加了一個名爲:rowtable
的類,但是當我刷新頁面時,表格不會在該類上使用樣式定義。此外,我嘗試使用引號,就像您在整個表格的課程tabledatos
上看到的那樣,但這不起作用。
如何向此代碼添加類以便我可以在style.css
文件上對其進行自定義?
在先進的感謝
你確定你有'rowtable'類?開發人員控制檯中的任何線索? –