- This topic has 5 replies, 2 voices, and was last updated 1 year, 11 months ago by David.
-
AuthorPosts
-
April 19, 2022 at 3:02 pm #2194039Sophia
Hi there,
I‘m trying to implement a local navigation to the archive-pages (I got a few of them). The navigation should be on the left sidebar and contain the links to all posts of the taxonomy – so it should be dynamic. Is there any way to do this with GeneratePress?
Nice regards,
SophiaApril 20, 2022 at 1:11 am #2194368DavidStaffCustomer SupportHi there,
just to be clear, on the archive page, you want to list all posts of that same taxonomy term in the sidebar ?
April 20, 2022 at 1:32 am #2194394SophiaYes, exactly – like a index of content of the archive page. And the index changes, when the user moves to another taxonomies archive page.
April 20, 2022 at 2:12 am #2194450DavidStaffCustomer SupportSorry for the questions, but does that not mean you will have duplicate posts effectively? As the archive will be listing the posts, and you will also have them listed in the sidebar ? What am i missing 🙂
May 2, 2022 at 2:26 am #2206182SophiaHi,
sorry for delated answer. No, I’m not duplicating – I was just wondering if there is a way to display a dynamic taxonomy archives list – so all the posts by taxonomys terms (I’ve got different taxonomies and therefor different archive-pages) as a list anchored to the post-id.
I would like to place the list in a sticky side bar as a local navigation on this side, because our costumer does not want to display just excerpts but the whole posts on the archive page. So it wouldn’t be very user friendly without the additional list…May 2, 2022 at 7:41 am #2206441DavidStaffCustomer SupportOk – so you could create your own Shortcode to display the list.
Try adding this PHP Snippet to your site:function db_show_posts_in_category() { $string = ''; $cat = get_queried_object()->term_id; $the_query = new WP_Query( array( 'cat' => $cat, 'posts_per_page' => 5 ) ); // The Loop if ( $the_query->have_posts() ) { $string .= '<ul class="category_posts_list">'; while ( $the_query->have_posts() ) { $the_query->the_post(); $string .= '<li>'; $string .= '<a href="' . get_the_permalink() .'" rel="bookmark">' . get_the_title() .'</a></li>'; } } $string .= '</ul>'; return $string; /* Restore original Post Data */ wp_reset_postdata(); } add_shortcode('show_cat_posts', 'db_show_posts_in_category');
That will create this shortcode:
[show_cat_posts]
Which you could add to your archive pages using a Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
-
AuthorPosts
- You must be logged in to reply to this topic.