[WordPress] Append WordPress Page Content From the Database
<?php | |
public function init() { | |
$page_id = get_option( 'acme_display_page_id', 0 ); | |
if ( 0 === $page_id ) { | |
return; | |
} | |
add_filter( 'the_content', array( $this, 'the_content' ) ); | |
} |
<?php | |
private function get_users() { | |
$args = array( | |
'orderby' => 'ID', | |
'role' => 'Editor', | |
); | |
$user_query = new \WP_User_Query( $args ); | |
return $user_query; | |
} |
<?php | |
private function get_user_markup( $user_query ) { | |
$content = ''; | |
if ( 0 === $user_query->get_total() ) { | |
return; | |
} | |
$users = $user_query->get_results(); | |
$content = '<ul>'; | |
foreach ( $users as $user ) { | |
$login = $user->data->user_login; | |
$content .= "<li>$login</li>"; | |
} | |
$content .= '</ul>'; | |
// Note: Use proper escaping or wp_kses to sanitize this data. | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment