Skip to content

Instantly share code, notes, and snippets.

@collegeman
Last active December 1, 2016 21:58
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 collegeman/932a94ef1980e25d760ea904c48ad43b to your computer and use it in GitHub Desktop.
Save collegeman/932a94ef1980e25d760ea904c48ad43b to your computer and use it in GitHub Desktop.
Hypothetical, simpler example of routing in WordPress.
<?php
$app->get('/author/{id}', function($id) {
$posts = get_posts( array(
'author' => $id,
) );
if ( empty( $posts ) ) {
return null;
}
return $posts[0]->post_title;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment