- This topic has 7 replies, 2 voices, and was last updated 3 years, 8 months ago by
David.
-
AuthorPosts
-
August 3, 2022 at 2:43 am #2301669
Tesco
I have a custom loop that uses Wp PageNavi plugin but it shows the navigation at the top of the page instead of showing it at the bottom as it should be.
Therefore I have two questions:
Any reason why this is happening?
The theme as custom navigation built in (if so, how can I call it in a shortcode)?
August 3, 2022 at 4:22 am #2301747David
StaffCustomer SupportHi there,
how is the custom loop created ? Can you share a link to where i can see it ?
August 3, 2022 at 4:37 am #2301765Tesco
Hi David,
Sorry, I cannot share a link mainly for two reasons: I’m working on localhost and my client has strict rules.
But I can share the loop with you, if that helps..?
Also:
Maybe (just maybe), this can be related?
August 3, 2022 at 5:50 am #2301831David
StaffCustomer SupportIn that other topic, you have multiple loops, if each loop requires its own pagination then that can be done IF the GB Query Loop block is used. It was built with that in mind and can handle multiple paginated loops.
If you’re not using that, then it requires Custom Development.
August 3, 2022 at 6:07 am #2301841Tesco
The shortcode is used (in the hook)
generate_after_content. So, in fact I just have one loop.Why is the wp navigation div ir rendered above the page and not at the end of the loop?
Here’s my loop in the shorcode:
if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } $posts_qt = 10; $args = array( 'showposts' => $posts_qt, 'paged' => $paged, 'orderby' => 'desc', ); $temp = $home_query; $home_query= null; $home_query= new WP_Query( $args ); if ($home_query->have_posts()) : while ($home_query->have_posts()) : $home_query->the_post(); //The loop goes here endwhile; if(function_exists('wp_pagenavi')) : wp_pagenavi( array( 'query' => $home_query) ); else : echo '<div class="navigation">'; echo '<div class="alignleft">'.previous_posts_link().'</div>'; echo '<div class="alignright">'.next_posts_link().'</div>'; echo '</div>'; endif; wp_reset_postdata(); else: wp_redirect( home_url(), 302); exit; endif;August 3, 2022 at 7:02 am #2301905David
StaffCustomer SupportThat would be hard for me to say, as i don’t see the entire picture and custom development is outside of our scope
One issue that may cause a problem is is usingechoto output content.
Shortcodes should only everreturncontent not output it.To use echo inside a shortcode you would need to use object buffering – see here for an example:
https://docs.generatepress.com/article/creating-a-shortcode/
August 3, 2022 at 7:25 am #2301928Tesco
David,
You where very useful!
Following your tips resolved my issue.
Thank you!
August 3, 2022 at 8:10 am #2302156David
StaffCustomer SupportGlad to be of help!
-
AuthorPosts
- You must be logged in to reply to this topic.