Site logo

[Resolved] Custom Post Archive Page

Home Forums Support [Resolved] Custom Post Archive Page

Home Forums Support Custom Post Archive Page

  • This topic has 5 replies, 2 voices, and was last updated 5 years ago by Elvin.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1685898
    Janine

    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.

    #1686179
    Elvin
    Staff
    Customer Support

    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.

    #1687257
    Janine

    Hi.

    I want to be able to manually sort my posts by subject matter on a custom archive page.

    Thank you.

    #1687449
    Elvin
    Staff
    Customer Support

    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

    #1687940
    Janine

    Thank you, Elvin.

    #1688874
    Elvin
    Staff
    Customer Support

    No problem. 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.