Community Forums › Forums › Archived Forums › Design Tips and Tricks › custom loop on page
Tagged: custom loop
- This topic has 6 replies, 3 voices, and was last updated 10 years, 5 months ago by
Genesis Developer.
-
AuthorPosts
-
June 19, 2015 at 4:41 pm #156854
mmjaeger
MemberHello
I'm a little lost at the moment - I've a page with a custom loop - what happens is that the page title is not shown when using the custom loop - how do you deal with this - one way as I see it is to put back the page title like this:printf( '<div class="entry"> <header class="entry-header"> <h1 class="entry-title">%s</h1> </header> </div>', get_the_title() );the other option I guess would be to run a 2nd loop after the page entry - am I missing something here - what's the preferred way to handle this?
Thank you in advance for your help.
June 19, 2015 at 7:22 pm #156873Christoph
MemberHi,
hmm... hard to tell without seeing your custom loop.
Did you end it with genesis();?
Here are some examples of custom loops, sorry if you already know about them:
gregrickaby.com/genesis-code-snippets/
gist.github.com/billerickson/3218052
genesissnippets.com/genesis-custom-loop/
June 19, 2015 at 8:09 pm #156879mmjaeger
MemberYes I did end it with genesis() - I basically have something like outlined at genesissnippets.com/genesis-custom-loop/ using a custom page template - everything works fine - I just don't know what the best way would be to show the page title since the custom loop replaces the primary loop, the page doesn't output its page title?
June 22, 2015 at 8:37 am #157159mmjaeger
MemberI'm still looking for some insight how to do this.
Thanks again.
June 22, 2015 at 9:53 am #157167Genesis Developer
MemberI used following code. It is showing Page Title and removing the Page Content.
<?php /** * Template Name: Custom Loop */ /** Replace the standard loop with our custom loop */ remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); add_action( 'genesis_after_loop', 'child_do_custom_loop', 20 ); function child_do_custom_loop() { global $paged; // current paginated page global $query_args; // grab the current wp_query() args $args = array( 'post_type' => 'listing', // exclude posts from this category 'paged' => $paged, // respect pagination ); add_action( 'genesis_entry_content', 'genesis_do_post_content' ); genesis_custom_loop( wp_parse_args($query_args, $args) ); } genesis();
June 22, 2015 at 9:56 am #157169mmjaeger
Memberso you're adding a secondary loop and not replacing the primary loop, right - does the pagination word on the secondary loop?
Thanks again.
June 22, 2015 at 10:27 am #157171Genesis Developer
Memberyes. pagination will work. Try once. You will modify the code. I am using "listing" post type in the loop
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.