Support » Fixing WordPress » How to query all posts from all custom post type

Viewing 2 replies - 1 through 2 (of 2 total)
  • You need categorization. Search for some plugin maybe.

    Moderator keesiemeijer

    (@keesiemeijer)

    moderator

    Try it with this in your theme’s functions.php:

    add_action( 'pre_get_posts', 'post_type_home_query' );
    function post_type_home_query( $query ) {
    	/* not an admin page and is it's the main query */
    	if ( !is_admin() && $query->is_main_query() ) {
    		if ( is_home() ) {
    			$args=array(
    				'public'   => true,
    				'_builtin' => false
    			);
    			$post_types = get_post_types( $args, 'names', 'and' );
    			if ( !empty( $post_types ) )
    				$query->set( 'post_type', array_keys( $post_types ) );
    		}
    
    	}
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to query all posts from all custom post type’ is closed to new replies.