Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin

tommcfarlin/00-the-init.php Secret

Last active Nov 9, 2016
Embed
What would you like to do?
[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
You can’t perform that action at this time.