0

I'm working on a site with a structure I haven't seen in the past. Specifically, the site has Inventory Items (custom post type 'item') that show on Item Archive and Item Single pages. For some of these 'Items', we will input a matching ACF Field (Auction ID) to associate them with each other.. eg. the items with the same Auction ID will not only show individually in inventory but will also show on an Auction Custom Post Type page (single). We'll also show a list of these Auctions on an Archive page.

So, here's the question. What would you WP Gurus recommend to structure this cleanly:

  1. Use Custom Post types (as I've began setting up) and code individual archive-item, single-item, archive-auction and single-action pages to display the loops. And use an ACF field on the Items, that I can call in the loop to just display those that have the matching ACF field (Auction ID)?

  2. Use Custom Post types with categories or another structural WP option?

Since we're not using any typical auction features (the auctions are head off site through an auction provider, these pages are just for representation and to link to that site), and we don't need ecommerce features, we prefer not to use an auction plugin, etc. and to just roll this from WP core. But, after digging into a mess we had to fix from a previous developer.. my head it just reeling. Just can't wrap my head around the best way to structure these content items.

Recap: Inventory Items are posted to the site (displayed on single-item.php templates) Some items will be associated (likely with an ACF Field) There are Auction posts on the site - with descriptions and additional event data as well as a display of Inventory Items that have matching ACF field data. Auctions have both archive-auction.php (for listing all auctions) and single-auction.php to show the individual auction post.

ALL Inventory Items will remain on the site, even after being sold (just displayed as 'sold'). This STATUS has not been configured yet. What is the easiest to loop with - ACF field? Taxonomy? Category?

Auctions will expire at a preset time (ACF Date Field in the Custom Post Type currently)

Really appreciate any suggestions or advice!

Here's my current loop:

`           <?php
            $today = date("Ymd");

            $loop = new WP_Query(
                array(
                    'post_type' => 'auction',
                    'posts_per_page' => 5,
                    'meta_key' => 'auction_date',
                    'orderby' => 'meta_value',
                    'order' => 'ASC',
                    'meta_query' => array( // WordPress has all the results, now, return only the events after today's date
                        array(
                            'key' => 'auction_date', // Check the start date field
                            'value' => $today, // Set today's date (note the similar format)
                            'compare' => '>=', // Return the ones equal or greater than today's date
                            'type' => 'DATE' // Let WordPress know we're working with date
                            )
                    )
                    /*
                    ,
                    'tax_query' => array( // Return only concerts (event-types) and events where "songs-of-ascent" is performing
                        array(
                            'taxonomy' => 'status',
                            'field' => 'slug',
                            'terms' => 'available',
                        ),
                    )
                    */
                )
            );
        if ( $loop->have_posts() ): 
            
            get_template_part( 'template-parts/content', 'auctions' );              

        else :

            get_template_part( 'template-parts/content', 'none' );

        endif; 
            wp_reset_postdata();
        ?>
        

`

0

This is a tough question to get an exact or correct answer to because it's subjective... for example, I'd not use ACF, but someone else would.

Here's my suggestion for how to streamline this, if I'm understanding it correctly...

Keep the Custom Post Type for 'Items' - then, I guess, keep using ACF to build the fields into the CPTs.

For the different displays you're using different templates. So one for single items, one for individual auctions, etc.

Then, make the auctions a taxonomy - you can also add custom term meta (as of WP 4.4) to taxonomies and custom taxonomies. (Previous method was to make the meta data wp_options and then associate the options with the taxonomies.)

Then you're just assigning 'Auctions' to the 'Items' and you can then build templates that dynamically load all of the items in an Auction.

From there you can apply ACF's date fields to different areas, etc.

1
  • Thanks for the reply. I'm using a CPT for Items and then using ACF fields for the data each Auction needs.. just as you suggested as well. I'm also using the single-auction.php and archive-auction.php templates to run the loops I can use a taxonomy for status,. but the loop wasn't working. Instead, I added an ACF field for a date, and am checking that to see if it's <= today's date (eg. is the auction passed, or current and in the future).. but putting that together the loop to display BOTH a group of current auctions and then a group of passed auctions is elusive. Updated post w/ loop
    – revive
    Mar 10 at 20:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.