Don’t Worry, You’re In The Right Place
A lot of these posts were originally on SureFireWebServices.com. So if you found them through search engines or clicking around, this is their new home :). Enjoy!
0

Create A Custom Loop without Genesis Hooks

I love the Genesis Framework and all of it’s flexibility. When you create a loop you can use different actions to unhook meta info, etc.

Well, what if you want to not go through all that trouble and just make a custom loop with your own code. Here’s how to do it:

The NEW Genesis Loop

So in order to add your custom loop the first thing you’re going to have to do is unhook the standard genesis loop.

Now that the standard loop is gone, let’s create our own loop.

So the first thing I did was add our new loop function to replace where the old one was. Then after that, I just added a standards wordpress loop.

This loop is very basic only displaying the title and the content. If you wanted though, you can go as crazy as you want with it.

There are tons of different ways to output the loop code too so don’t think that this is it. Combine this with Genesis Grid Style Page Template with Custom Post Type and you can literally create any type of loop you want!

[sws_yellow_box box_size=””]

Hate Coding and Trying to figure this loop stuff out?

I admit, sometimes I do. It’s fun for me but sometimes I just don’t have the time to make a custom loop with custom code.

In comes the best plugin in the world, WP Views. I’ll eventually write a review on it, but when you want to do a custom loop display, or single page display quick and easy without typing in code, this is the plugin you need. (Yes it’s an affiliate link but the plugin is damn incredible).[/sws_yellow_box]

What do you think?

Advertisement
About the Author
What's UP! This is my site, I write 99% of the articles on here. I'm also the owner of SureFireWebServices.com. I help out a lot of developers and designers getting into the web game. Helping is fun for me, so feel free to ask me any questions! I've made courses and have a membership as well to help get you on your feet!

0 comments on Create A Custom Loop without Genesis Hooks

  1. ian says:

    hi,

    i try to use the custom loop without genesis hook, but it cause the pagination missing.

    remove_action(‘genesis_loop’, ‘genesis_do_loop’);//remove genesis loop
    add_action(‘genesis_loop’, ‘special_loop’);//add the special loop
    function special_loop() {
    $loop = new WP_QUERY( $args );

    while ( $loop->have_posts() ) : $loop->the_post();
    <div id="post-” class=”coupon”>
    <a href="”>the coupon link

    endwhile;
    }
    genesis();

    but if in my function is just use
    genesis_custom_loop(wp_parse_args($query_args, $args));

    then the pagination work, may i know what is the reason and how you do it without using genesis hook ?

    1. Jonathan says:

      Since you’re not using the Genesis Hooks, standard loop rules would apply. You would have to pass pagination in your $args:

      $args = array(
      ‘posts_per_page’ => 6,
      ‘post_type’ => ‘post’,
      ‘paged’ => get_query_var( ‘paged’ ),
      );

      You can check out the wordpess codex for more info on that or bill ericksons site, http://www.billerickson.net/code/pagination-in-a-custom-query/

  2. Thierry says:

    Hi Jonathan, I use Genesis 1.9.1 the new version and I have a page_listing in my child folder. I tried the codes above but it doesn’t change anything at all. Why would that be?

    Thanks

    1. Jonathan says:

      The loop code changed in 1.9. Now the query has to be called before the loop. Take a look at Travis’ post here: http://wpsmith.net/2013/genesis/genesis-grid-loop-in-genesis-1-9/ I’ll update the post soon to reflect the new changes.

      1. Thierry says:

        thanks Jonathan.

  3. Peter Ruchti says:

    You just saved me tons of time… Thank you so much!

    1. Jonathan says:

      That’s my aim!! =) Very welcome!

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top