Archived topic
Custom Post Archive Page
5 replies · Started by Janine on March 7, 2021
Hi.
What would like to create a custom archive page that lists all of my posts by category. And not the category names.
What is the easiest way to accomplish that in Gutenberg?
Thank you.
Hi there,
I'm not exactly sure I understand how you want the posts sorted but you should be able to create an archive page with Gutenberg using WP Show Posts plugin for this. http://wpshowposts.com/
Do you have any reference sites you'd like to duplicate so we could better understand how you want the post list to be ordered/sorted? Let us know.
Hi.
I want to be able to manually sort my posts by subject matter on a custom archive page.
Thank you.
You can create a custom archive page with this arrangement:
Edit the page and add a WPSP list for each category you have.
You then make sure these WPSP list you've added has its proper category applied to it.
Alternatively, you can make an automated WPSP list for each categories by using this PHP snippet to allow for use of [cat_listing id=""].
add_shortcode('cat_listing',function($atts){
ob_start();
$atts = shortcode_atts( array(
'id' => ''
), $atts, 'cat_listing' );
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
) );
foreach( $categories as $category ) {
$category_link = sprintf(
'<h2><a href="%1$s" alt="%2$s">%3$s</a></h2>',
esc_url( get_category_link( $category->term_id ) ),
esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ),
esc_html( $category->name )
);
echo $category_link;
$settings = array(
'tax_term' => $category->name,
);
wpsp_display( $atts['id'], $settings );
}
return ob_get_clean();
});
After applying this you should be able to use [cat_listing id=""] where id="" is the ID of the WPSP id you want to use.
Example: [cat_listing id="4739"]
See it in action on this demo page: [cat_listing] demo page
Thank you, Elvin.
No problem. :)