Created
January 26, 2018 12:05
-
-
Save janneleppanen/6e2d779479c752de7984c3ac2f6cf591 to your computer and use it in GitHub Desktop.
WordPress: Show page instead of archive page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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