• Resolved Hud1ai2

    (@hud1ai2)


    Hi there,
    I’ve made custom post type “products” for promo banners which contains name, link and image – all made with ACF. Is there a way, how to go through these posts and randomly choose one of them (one product) and display it on front end? Is it possible to do that without WP query? Just a loop through posts, get their IDs and then based on ID of one of them show what I need. Thanks!

    • This topic was modified 2 years, 8 months ago by Hud1ai2.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    All in all yes, there’s ways to do this. It won’t be with Custom Post Type UI alone, as we don’t have any functionality around content display.

    If you’re wanting to avoid coding in general, then something like https://wordpress.org/plugins/random-post-on-refresh/ looks like it’s exactly what you need.

    Otherwise, you’re going to want to make use of WP_Query in some way if you’re not wanting to use someone else’s plugin.

    Thread Starter Hud1ai2

    (@hud1ai2)

    Ok, thanks a lot. I thought, there is a way to do that without WP_Query. Just to use some loop through my post type and choose one of them and display it. I’m affraid, that WP Query will be affected by repeaters from Oxygen.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Noted. WP_Query would be getting used at some point along that entire line of execution because it needs to fetch the posts at some point. I believe it even may be used if providing a list of IDs.

    I think that plugin is worth a try just to see how things go with it. Perhaps if necessary avoid using it within a part of Oxygen that isn’t repeater based.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Random displaying of post’ is closed to new replies.