根据您的情况,最简单,最好的方法是在您的主题中添加一个shortcode.
如果将此代码添加到主题的functions.php文件中,则可以通过在任何页面或帖子中添加[角色表]来在任意位置显示信息.
// add the shortcode [persona-table], tell WP which function to call
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 = '
$content .= '
FirstnameLastnamePoints';$results = $wpdb->get_results( ' SELECT * FROM persona' );
foreach ( $results AS $row ) {
$content = '
';// Modify these to match the database structure
$content .= '
' . $row->firstname . '';$content .= '
' . $row->lastname . '';$content .= '
' . $row->ID_per . '';$content .= '
';}
$content .= '
';// return the table
return $content;
}