WordPress.org

Support

Support » How-To and Troubleshooting » Set a Menu Item as 'current menu item' on front page

Set a Menu Item as 'current menu item' on front page

  • Hi there, I’m not all that sure if this belongs in this category. After hours of trying and googling I need help…

    Anyways, I’ve created some custom post types. Let’s say my custom post type is customposttype1. I’ve used the following code to achieve that the posts of this custom post type are being display on the front page:

    add_filter( 'pre_get_posts', 'custom_front_page' );
    function custom_front_page( $wp_query ) {
    	if ( is_home() && $wp_query->is_main_query() )
    		$wp_query->set( 'post_type', array( 'stories' ) );
    
    	return $wp_query;
    }

    In my menu I’ve added the custom link mysite.com/customposttype1/ which displays my archive listing all the posts of this custom post type.

    Now what I’d like is to have pre-selected this menu item when arriving on the site.

    Is there a way to achieve this?

  • The topic ‘Set a Menu Item as 'current menu item' on front page’ is closed to new replies.
Skip to toolbar