WordPress.org

Ready to get started?Download WordPress

Forums

Set a Menu Item as 'current menu item' on front page (1 post)

  1. fabian.schmid
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic