In the WPDevDesign Facebook group a user asked:
Just wondering if its possible to have a message/content to appear when a repeater is empty?
To explain: The client's site has an Employment page. I've made a CPT and each new job is it's own post. The repeater on the static Employment page displays all jobs available. Nice and simple, works well.
However, there will be times when the client won't have jobs listings, so instead of a blank page because the repeater won't find any job posts, I would like to display a message.
This members-only tutorial provides the steps to define a custom function that returns the number of published posts of a specified post type and use this in the built-in Dynamic Data condition of Oxygen to either output a Repeater or a Text component depending on whether there is at least one published entry.
Install and activate Code Snippets plugin.
Go to Snippets > Add New.
Title: Get number of published entries for a given post type
This is a premium members-only content.
To view the rest of the content, please sign up for membership ($47/month or $499 one-time).
Already a member? Log in below or here.