Skip to content

Instantly share code, notes, and snippets.

@janneleppanen
Created January 26, 2018 12:05
Show Gist options
  • Save janneleppanen/6e2d779479c752de7984c3ac2f6cf591 to your computer and use it in GitHub Desktop.
Save janneleppanen/6e2d779479c752de7984c3ac2f6cf591 to your computer and use it in GitHub Desktop.
WordPress: Show page instead of archive page
function show_page_instead_of_archive_page( $request ) {
if ( key_exists( 'category', $request ) ) {
$slug = $request['category'];
$queried_post = get_page_by_path( $slug, OBJECT, 'page' );
if ( $queried_post ) {
$request['page_id'] = $queried_post->ID;
unset( $request['category'] );
}
}
return $request;
}
add_filter( 'request', 'show_page_instead_of_archive_page' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment