Support » Plugin: Custom Post Type UI » CPT Archive Page not working

  • Resolved revive

    (@revive)


    Hello,
    This is the first time I’ve used CPTUI and I’ve got to say, great work! Sure makes cranking our several CPTs fast and easy.

    I’m working on a site with Inventory Items (item CPT) that we will group (by ACF field #) and show on an Archive Page (auction CPT). So, I’ve created both an Item page and an Auction page (the auction page shows info of the auction event and all the related item pages being sold in that auction).
    I’ve also created the archive-auction.php page.
    I’ve updated permalinks.
    Made sure no other categories, taxonomies, are named anything like item or auction.

    But when I go to the Auction archive page (view front end archive from CPTUI) the archive.php files loads, instead of the archive-auction.php with the correct loop in it.

    Any idea what might be happening?

    Also, any suggestions on structuring the CPT vs Taxonomies for this example:
    Site contains Inventory Items (CPT ‘item’), some will have a ACF field related to an Auction ID and we’ll want to show those on an Auction Archive for a period of time. Some will be shown on a Liquidation page (CPT Liquidation, similar to auction, just different loop to show different data, and post expires at later date).
    All items will remain on the site, even after sale. Their status from available to sold is the only thing that will change.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter revive

    (@revive)

    Here is the code for the Auction post type:
    function cptui_register_my_cpts_auction() {

    /**
    * Post Type: Auctions.
    */

    $labels = [
    “name” => __( “Auctions”, “wp-bootstrap-starter” ),
    “singular_name” => __( “Auction”, “wp-bootstrap-starter” ),
    “menu_name” => __( “Auctions”, “wp-bootstrap-starter” ),
    “all_items” => __( “All Auctions”, “wp-bootstrap-starter” ),
    “add_new” => __( “Add Auction”, “wp-bootstrap-starter” ),
    “add_new_item” => __( “Add New Auction”, “wp-bootstrap-starter” ),
    “edit_item” => __( “Edit Auction”, “wp-bootstrap-starter” ),
    “new_item” => __( “New Auction”, “wp-bootstrap-starter” ),
    “view_item” => __( “View Auction”, “wp-bootstrap-starter” ),
    “view_items” => __( “View Auctions”, “wp-bootstrap-starter” ),
    “not_found” => __( “No Auctions Found”, “wp-bootstrap-starter” ),
    “featured_image” => __( “Auction Cover Image”, “wp-bootstrap-starter” ),
    “set_featured_image” => __( “Set Auction Cover Image”, “wp-bootstrap-starter” ),
    “remove_featured_image” => __( “Remove Auction Cover Image”, “wp-bootstrap-starter” ),
    “use_featured_image” => __( “Use Auction Cover image”, “wp-bootstrap-starter” ),
    “archives” => __( “Auction Archives”, “wp-bootstrap-starter” ),
    “items_list” => __( “Auction List”, “wp-bootstrap-starter” ),
    ];

    $args = [
    “label” => __( “Auctions”, “wp-bootstrap-starter” ),
    “labels” => $labels,
    “description” => “”,
    “public” => true,
    “publicly_queryable” => true,
    “show_ui” => true,
    “show_in_rest” => true,
    “rest_base” => “auction”,
    “rest_controller_class” => “WP_REST_Posts_Controller”,
    “has_archive” => “auctions”,
    “show_in_menu” => true,
    “show_in_nav_menus” => true,
    “delete_with_user” => false,
    “exclude_from_search” => false,
    “capability_type” => “post”,
    “map_meta_cap” => true,
    “hierarchical” => false,
    “rewrite” => [ “slug” => “auction”, “with_front” => true ],
    “query_var” => “auction”,
    “supports” => [ “title”, “thumbnail” ],
    ];

    register_post_type( “auction”, $args );
    }

    add_action( ‘init’, ‘cptui_register_my_cpts_auction’ );

    Thread Starter revive

    (@revive)

    Solved. #embarrassing – my editor was showing the file in the file list, but it was located in a sub-folder inadvertently. #facepalm

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    So you’re good on all parts now? or is there some lingering spots needing help with?

    Thread Starter revive

    (@revive)

    Micheal,
    Yes, once I opened the file (from the editor) in Finder.. and saw it was in the wrong folder. Never seen textmate show a file IN the main dir, when it was in a sub dir!

    Quick question.. if you’re up for it.

    The structure for this site is killing my brain cells LOL
    It’s a pretty basic site, basically a listing of items, and groups of items on Auction pages, that just link off to an auction site.. no auction features take place on the site.
    So, here’s my question… what would you say is the easiest way to structure/code the loops for Items so that I can:

    1) Separate items that are Available and Sold (Current Items, Past Items) – would you use an ACF field? Taxonomy? Category?

    2) Display a group of Items that have a matching ACF field (Auction ID) on an Auction Page (Auction CPT) We have an archive-auction.php to show all Auctions and a single-auction.php for the individual auction loop. Running the loop only for Custom Posts of Item THAT have the matching Auction ID ACF field, is proving elusive.. suggestions? easier way?

    I understand this is page is for CPTUI specifically, and this only partially pertains to CPTUI…so, if you can’t, or don’t have time to, answer it, I understand.
    I appreciate any suggestions or pointers to resources you have!

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    1) I could see a “status” taxonomy being useful for that one.
    2) Dunno about a dedicate permalink for this one, but beyond that it sounds like either a tax query or meta query on a page of some sort could probably handle fetching those. You could treat the auction ID as either a term or an ACF meta value.

    Thread Starter revive

    (@revive)

    Thanks for the response! I was debating between using a tax field or ACF field. I decided to try the ACF date field, and if it’s ‘current’ (<= todays date) then run in a Current Auctions loop, else run in the Past Auctions loop.

    Yeah, the meta query is what I had started with,. just wasn’t sure if there was a ‘cleaner’ way to loop through the items.

    Appreciate the advice on this and the help with CPTUI

    Plugin Author Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘CPT Archive Page not working’ is closed to new replies.