Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active November 9, 2016 15:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/cfca668f3d1ade8335611f1434b94cf7 to your computer and use it in GitHub Desktop.
Save tommcfarlin/cfca668f3d1ade8335611f1434b94cf7 to your computer and use it in GitHub Desktop.
[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