Browse: Home / Snippets /

Override the change to post_type set by the Post Categories and Tags plugin

Contents


Snippet #

Important: All snippets are provided as-is without support or guarantees. These snippets are provided as guidelines for advanced users looking to customize LearnDash. For any additional help or support with these snippets, we recommend reaching out to a LearnDash Expert.

add_action( 'pre_get_posts', function( $query ) {

	$queried_object = get_queried_object();
	if ( $queried_object instanceof WP_Post ) {
		if ( ( $queried_object->post_type == 'page' ) && ( $queried_object->ID == 464 ) ) {
			if ( ( isset( $query->query_vars['post_type'] ) ) && ( !empty( $query->query_vars['post_type'] ) ) && ( is_string( $query->query_vars['post_type'] ) ) ) {
				if ( ( isset( $query->query['post_type'] ) ) && ( !empty( $query->query['post_type'] ) ) && ( is_string( $query->query['post_type'] ) ) ) {
					if ( $query->query_vars['post_type'] != $query->query['post_type'] ) {
						$query->set( 'post_type', $query->query['post_type'] );
					}
				}
			} 
		}
	}
}, 999 );