Archived topic
Can the Elements - Archive Navigation work on a custom results.php page?
4 replies · Started by Spencer on December 23, 2021
Hi there,
I am using a custom results.php page to show the results of a filter. (search and filter pro on ACF fields)
I did have it set up at one stage to use the Archive page and the Archive Navigation worked great.
I didn't think it was working on the reults.php pag so I installed wp-navi to see if that could help me.
I noticed that it was actually showing on the second page of results.
I am just wondering if I can get it working on the results.php page so I can get rid of the wp-navi (trying really hard to use minimal or only generate press plugins.
This is page 2 of the results - https://dev.scenichelicopters.com.au/margaret-river-helicopter-flights-and-tours/?sf_paged=2
This is the bottom of the code - is there some generatepress magic hook or action that I am missing?
<div class="st-button-wrapper">
<div class="st-button-col">
<a class="button" href="<?php the_field('book_url'); ?>">Book Now</a>
</div>
</div>
</div>
</div>
</div>
<?php
}
?>
<div class="pagination">
<div class="nav-previous"><?php next_posts_link( 'Older posts', $query->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( 'Newer posts' ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists('wp_pagenavi'))
{
echo "<br />";
wp_pagenavi( array( 'query' => $query ) );
}
?>
</div>
<?php
}
else
{
echo '<div class="not-found-container">';
echo '<div class="not-found-item">';
echo '<h1>Uh oh</h1>';
echo '<p>We dont seem to have tour for that search Please refine your filter and try again or get in touch</p>';
echo '</div>';
echo '</div>';
}
?>
Many thanks!
Hi there,
i can see the Block Element Archive Navigation button container on the first page - its just empty. Is there two buttons in the container one of which is set to Next page ?
Hi David,
Yes I think so, I have a froward and back button dynamically linking to next and previous posts.
https://drive.google.com/file/d/1KpHdmoSKLaFG-_8WMf7KKDLc8M7eWgLE/view?usp=sharing
Thanks
Actually it seems that the page-navi plugin is helping it load, as it does not show at all when the plugin is disabled.
Probably because it is not an archive page?
Is there a way I can manually add the hook?
So here is where the Themes Post Navigation gets hooked in:
the hook it uses is the generate_after_loop which is found in the archives.php.
Although you could include the hook in your own template, to be honest i am not sure what it would do.