Gallery layout from Custom Post Type (5 posts)

  1. conorp
    Posted 5 years ago #

    Hi guys,

    I know that title is vague, and I'll try my best to explain my issue.

    For some background, I have a Custom Post Type called "sale". I use the WP featured image for the image output, and have various meta options (custom fields) to display the other data. The post editor box itself is not used.

    The end output is http://d.pr/3E5z .

    Now what I am trying to do is get a grid based gallery sort of layout to 'list' all the posts in the "sale" post type. Basically I want the WP featured image and post title to be listed, which would then link to the post. I would imagine I would do this with a page template.
    The final kind of functionality I am after looks quite similar to http://www.fbcattle.com.au/genetic_factory_sires.htm

    I hope that made some sort of sense.

  2. conorp
    Posted 5 years ago #

    How do use custom post type archives work? I have added 'has_archive' => true

  3. Chip Bennett
    Theme Review Admin
    Posted 5 years ago #

    Refer to Template Hierarchy

    For a CPT archive index template file, use archive-{post-type}.php

    (For reference, for a CPT single post, use single-{post-type}.php.)

  4. conorp
    Posted 5 years ago #

    Hi Chip,

    Thanks for the reply.
    I have now got archive-sale.php working, so that /sale/ now displays a list of all the posts from the sale post type. However as the post editor itself is empty due to the use of Custom Fields, no content is actually displayed.

    Now the content itself doesn't worry me, however I'm still unsure how to get the post thumbnails to display with the post on the archive page.


  5. Chip Bennett
    Theme Review Admin
    Posted 5 years ago #

    Hey Conor,

    No need to call the_content(); just call the_post_thumbnail() directly, wherever needed inside the Loop.

Topic Closed

This topic has been closed to new replies.

About this Topic