WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #16025, comment 5


Ignore:
Timestamp:
03/04/2011 03:59:45 AM (7 years ago)
Author:
anmari
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #16025, comment 5

    initial v1  
    1313function a_page_is_a_page_we_need_no_more($q) { 
    1414// removes category and taxonomy query vars from page queries
    15 // the logic being that if we are querying a page, then categories and taxonomies are not relevant and can be ignored. 
    16 // the category and taxonomy are still there to be used by the event shortcode logic.
    17 // possibly one should also look at unsetting the more sophisticated tag_in etc vars, but for now this will do me
     15// the logic being that if we are querying a page and we already know the page id, then additional queries and categories and taxonomies are not relevant and can be ignored. 
     16// the queries vars, category and taxonomy are still there to be used by the event shortcode logic within the page.  THis way we at least get a page not a 404.
    1817
    19         if (isset($q->query_vars) and  $q->query_vars['page_id']) {  // unset categoreids and taxos
     18        $possible_parameters = array (
     19                'author'
     20                , 'author_name'
     21                , 'cat'
     22                , 'category_name'
     23                , 'tag'
     24                , 'tag_id'
     25                , 'category__in'
     26                , 'category__not_in'
     27                , 'category__and'
     28                , 'post__in'
     29                , 'post__not_in'
     30                , 'tag__in'
     31                , 'tag__not_in'
     32                , 'tag__and'
     33                , 'tag_slug__in'
     34                , 'tag_slug__and'
     35                , 'meta_key'
     36                , 'meta_value'
     37                , 'preview'
     38                , 's'
     39                , 'sentence'
     40                , 'fields'
     41                , 'second'
     42                , 'minute'
     43                , 'hour'
     44                , 'day'
     45                , 'monthnum' //?monthnum=3
     46                , 'year' //?year=2005  posted in,
     47                , 'w'
     48               
     49        );
     50
     51        if (isset($q->query_vars) and (
     52                (!empty( $q->query_vars['page_id'])) or
     53                (!empty( $q->query_vars['page'])) or
     54                (!empty( $q->query_vars['pagename']))) 
     55                ) {     
     56                // then we already know our page, lets unset the rest from this query variable.  They will still be accessible to the shortcode.
     57                // first unset all the event taxonomies we use - (should we just do all taxonomies anyway to avoid 404 ? ?)
    2058                $opt  = get_option( 'amr-event-taxonomies' );
    2159                if (!empty ($opt)) {
     
    2563                                        unset($q->query_vars[$taxonomy['name']]);
    2664                                        }               
    27                         unset($q->query_vars['category_name']);
     65                       
    2866                        }
     67                }
     68                foreach ($possible_parameters as $value ) { 
     69                        unset($q->query_vars[$value]);
    2970                }
    3071        }
     
    3374
    3475
     76}}}
    3577
    3678
    37 }}}
    38 
    39 Now just to figure out why the metabox is not appearing and custom columns in the edit screen!
    40