WordPress.org

Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #16373, comment 11


Ignore:
Timestamp:
01/19/2014 12:33:20 AM (8 years ago)
Author:
chipbennett
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16373, comment 11

    v1 v2  
    1313                        if ( '' != get_query_var( 'foobar' ) ) { // Registered custom query var
    1414                                $query->set( 'page_id', get_option( 'page_on_front' ) );
    15                                 $query->is_home = false;
    1615                                $query->is_page = true;
     16                                $query->queried_object = get_post(get_option('page_on_front') );
    1717                        }
    1818                }
     
    2020}
    2121add_action( 'pre_get_posts', 'themeslug_force_static_front_page' );
    22 
    23 function themeslug_force_front_page_template( $template ) {
    24         if ( '' != get_query_var( 'foobar' ) ) { // Registered custom query var
    25                 return get_front_page_template();
    26         }
    27         return $template;
    28 }
    29 add_filter( 'template_include', 'themeslug_force_front_page_template' );
    3022}}}
    3123
    32 == Edit ==
     24== Edit (2) ==
    3325
    34 Actually, the `pre_get_posts` is ''not'' working. Only the `template_include` is working to force the front page template. So, partial work-around.
     26Edited to add a functional workaround, that results in `is_front_page()` returning `true`.