beans_loop_template

Echo loop template part.

beans_loop_template( string $id = false )

Return: (void)

Parameters

NameTypeRequiredDefaultDescription
$idstringfalsefalseThe loop ID is used to filter the loop WP_Query arguments.

Source

function beans_loop_template( $id = false ) {

	// Set default loop id.
	if ( ! $id ) {
		$id = 'main';
	}

	// Only run new query if a filter is set.
	if ( $_has_filter = beans_has_filters( "beans_loop_query_args[_{$id}]" ) ) {

		global $wp_query;

		/**
		 * Filter the beans loop query. This can be used for custom queries.
		 *
		 * @since 1.0.0
		 */
		$args = beans_apply_filters( "beans_loop_query_args[_{$id}]", false );
		$wp_query = new WP_Query( $args );

	}

	// Allow overwrite. Require the default loop.php if not overwrite is found.
	if ( '' == locate_template( 'loop.php', true, false ) ) {
		require( BEANS_STRUCTURE_PATH . 'loop.php' );
	}

	// Only reset the query if a filter is set.
	if ( $_has_filter ) {
		wp_reset_query();
	}

}