Skip to content

Instantly share code, notes, and snippets.

@reasonstousegenesis
Created October 16, 2015 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reasonstousegenesis/8fb5893a60f481e0b00f to your computer and use it in GitHub Desktop.
Save reasonstousegenesis/8fb5893a60f481e0b00f to your computer and use it in GitHub Desktop.
Remove the loop with Genesis
<?php
// Paste the code BELOW this line into your child theme functions.
/**
* Remove the loop with Genesis
*
* @author Reasons to Use Genesis
* @link http://reasonstousegenesis.com/genesis-do-loop/
*/
remove_action( 'genesis_loop', 'genesis_do_loop' );
@wajidalitabassum143
Copy link

wajidalitabassum143 commented Aug 26, 2021

<?php

/** Replace the default loop with our custom **/
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'our_custom_loop' );

/** Custom  loop **/
function our_custom_loop() {
if ( have_posts() ) :

		do_action( 'genesis_before_while' );
		while ( have_posts() ) : the_post();

			do_action( 'genesis_before_entry' );

			printf( '<article %s>', genesis_attr( 'entry' ) );

				do_action( 'genesis_entry_header' );

				do_action( 'genesis_before_entry_content' );

				printf( '<div %s>', genesis_attr( 'entry-content' ) );
				
				//do_action( 'genesis_entry_content' ); //Remove standard excerpt
				
				echo genesis_do_post_image(); //Add in featured image
				
				echo the_excerpt_max_charlength(200); //change amount of characters to display
				
				echo '</div>';

				do_action( 'genesis_after_entry_content' );

				do_action( 'genesis_entry_footer' );

			echo '</article>';

			do_action( 'genesis_after_entry' );

		endwhile; //* end of one post
		do_action( 'genesis_after_endwhile' );

	else : //* if no posts exist
		do_action( 'genesis_loop_else' );
	endif; //* end loop

}

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