Skip to content

Instantly share code, notes, and snippets.

@halfempty
Created May 19, 2015 05:51
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 halfempty/bd298513f47c52763857 to your computer and use it in GitHub Desktop.
Save halfempty/bd298513f47c52763857 to your computer and use it in GitHub Desktop.
WordPress Decoy Page
<?php
function decoy_page( $query ) {
global $wp;
if ( !is_admin() && $query->is_main_query() ) {
if ( ( $query->get( 'page_id' ) == get_option( 'page_on_front' ) && get_option( 'page_on_front' ) ) || empty( $wp->query_string ) ) {
echo 'This displays when set to A Static Page and the homepage is showing.';
set_query_var( 'pagename', 'home' );
}
}
}
add_action( 'pre_get_posts', 'decoy_page' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment