Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Filters loop template part #77

Open
ehababdo opened this issue Nov 29, 2017 · 1 comment
Open

Add Filters loop template part #77

ehababdo opened this issue Nov 29, 2017 · 1 comment

Comments

@ehababdo
Copy link

For Example - filter is set

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 );

	}
	//  beans template filter is set.
	$templates = beans_apply_filters( "beans_template", false );
	$templates = ($templates) ? $templates : BEANS_STRUCTURE_PATH . 'loop.php';
	$file = basename($templates);
	if ( '' == locate_template( $file, true, false ) ) {
		require( $templates );
	}
	// Only reset the query if a filter is set.
	if ( $_has_filter ) {
		wp_reset_query();
	}
}

add_filter

	beans_add_filter('beans_template', 'beans_post_template');
	function beans_post_template() {
		if (is_singular('post')) {
			$file = BEANS_STRUCTURE_PATH . 'post.php';
			return $file;
		} 
	}
@hellofromtonya
Copy link
Contributor

@ehababdo I owe you a big apology for such a huge delay in getting back to you on your filter request. I'm very sorry.

Let's talk about your filter request. You'd like the ability to filter the loop template in your child theme.

Tell me more.

A few questions I have are:

  • Do you have different loop structure files for different templates and purposes?
  • Could you use loop.php and then switch what you need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants