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.

Repeater outputting post titles when there is at least 1 portfolio item
A custom text message when there are no portfolio items

Step 1

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 $399 one-time).

Already a member? Log in below or here.

Need help implementing a tutorial in your site or want to hire me for custom work?


Find the article helpful and wish to donate?



You need to be logged in to view and post comments.
Not a member yet? Join here.
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram
%d bloggers like this: