• I am working on building a very simple shopping cart for a site ( I will be using the Ultra simple pay pal cart)

    I have set up a Custom post type so that the user can add products like adding a blog post (the easier the better).

    What I would like to do is organize the CPT archive page by category type.

    So let’s say web person comes to the site, clicks on store, they would then be directed to the CPT archive page that would be laid out something like

    heading for product type one:
    product 1 product 2 product 3

    Heading for Thingy two:
    Thingy 1 Thingy 2 Thingy 3

    from there once they click on a product or thingy, they would be takern to that page.

    Is this at all possible?

    Thanks all!

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Yes!

    Create a custom template for your CPT archive page named following the format archive-{post_type}.php. The easiest way to setup the template is to get a list of all terms for the product type taxonomy and step through each term in turn. This is the outer loop. The inner loop is run from a query of all CPTs that are assigned to the current term of the outer loop. Each title of the query results is output in turn, which is also a permalink to the related CPT single page.

    If you’re good with SQL, a more efficient approach is to simply query all CPTs grouped by the product type taxonomy terms. The the single loop would need to somehow detect a term transition in order to output the group title content and such before listing each title in the related group.

Viewing 1 replies (of 1 total)

The topic ‘Archive page sorted by category?’ is closed to new replies.