Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #17590, comment 8


Ignore:
Timestamp:
04/11/2012 04:41:37 PM (12 years ago)
Author:
daveleeone
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #17590, comment 8

    v1 v2  
    1 Hi Tobias, thanks for reply.
    2 I have not seen, unfortunately, you've written back to me.
    3 
    4 here is the code:
    5 
    6 function file:
    7 {{{
    8 function my_page_css_class( $css_class, $page ) {
    9         global $post;
    10         if ( $post->ID == $page->ID ) {
    11                 $css_class[] = 'current_page_item';
    12         }
    13         return $css_class;
    14 }
    15 add_filter( 'page_css_class', 'my_page_css_class', 10, 2 );
    16 
    17 }}}
    18 
    19 
    20 template file:
    21 {{{
    22 <?php
    23 // create a ID of parent page to use the wp_list_page as submenu
    24                         if ($post->post_parent) {
    25                                 $ancestors=get_post_ancestors($post->ID);
    26                                 $root=count($ancestors)-1;
    27                                 $parent = $ancestors[$root];
    28                         } else {
    29                                 $parent = $post->ID;
    30                         }
    31 
    32 ?>     
    33 
    34 <ul class="submenu">
    35 <?php
    36 // create a Submenu for CPT's
    37 
    38         $args = array(
    39         'post_type'     =>      'event',
    40         'child_of'      =>      $parent,
    41         'title_li'      =>      __('')
    42 );
    43 wp_list_pages( $args );
    44 ?>
    45 </ul>
    46 }}}
    47 
    48 
    49 jquery file
    50 
    51 {{{
    52  $(document).ready(function(){
    53         $('.submenu li:has(li.current_page_item)').addClass('parent_page_item');       
    54 
    55 });
    56 }}}
    57 
    58 I hope it helps.
    59 if you make it I'll pay you a beer :)
     1remove my comment and repost it in the support forum
     2[http://wordpress.org/support/topic/current_page_item-hack-for-custom-post-typs?replies=2#post-2744994]