Skip to content

Instantly share code, notes, and snippets.

@QuantaTec
Last active September 14, 2016 10:19
Show Gist options
  • Select an option

  • Save QuantaTec/f8f3d495d3484b9f6ca7188fb2c9d74f to your computer and use it in GitHub Desktop.

Select an option

Save QuantaTec/f8f3d495d3484b9f6ca7188fb2c9d74f to your computer and use it in GitHub Desktop.
Add menu item highlight support for Property Listing Archive page
<?php
/*
* =============================================================================
* Add menu item highlight support for PropertyHive Listing / Archive page
* =============================================================================
* =============================================================================
*/
function qt_theme_ph_add_current_nav_class( $classes, $item ) {
$qt_classes= 'current_page_item current-menu-item active';
if ( is_post_type_archive('property') && isset( $item->url ) ) {
$propertyhive_search_results_page_id = get_option( 'propertyhive_search_results_page_id' );
$propertyhive_search_results_page_url = get_permalink( $propertyhive_search_results_page_id );
if( $propertyhive_search_results_page_id && $propertyhive_search_results_page_url == $item->url ) {
$classes[] = $qt_classes;
}
}
return $classes;
}
add_action( 'nav_menu_css_class', 'qt_theme_ph_add_current_nav_class', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment