Skip to content

Instantly share code, notes, and snippets.

@wpmark
Created September 9, 2018 10:52
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 wpmark/c7e330da89c1c1cc5f43a1bfd4a1909a to your computer and use it in GitHub Desktop.
Save wpmark/c7e330da89c1c1cc5f43a1bfd4a1909a to your computer and use it in GitHub Desktop.
Extending a WP_Query with a callback example.
<?php
/**
* Changes the job query to show only 5 posts per page.
*
* @param array $args The current query args.
* @return array The modified query args.
*/
function wpmark_alter_job_query_args( $args ) {
// change the number of posts per page to 5.
$args['posts_per_page'] = 5;
// return the args.
return $args;
}
add_filter( 'wpmark_job_query_args', 'wpmark_alter_job_query_args' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment