How to get count of settings set within a Customizer section?
-
In a custom theme, I’ve created a section in Customizer where the user can add any social media links they have (eg, the URLs for their Facebook, Twitter, email, etc).
I’ve called the section ‘social-media’.
I can access the individual items, of course, via something like:
$twitter_url = get_theme_mod('twitter-url');
.But, how can I retrieve a count of settings that contain values?
For example, maybe they’ve only entered their Facebook and Twitter URLs, but nothing else. In that case, I’d like to be able to do something like:
$setting_count = count( get_theme_mods( 'social-media') );
and get a result of 2.However, it appears that get_theme_mods() returns an array that contains a list of ALL settings, regardless of section they’re in. Does something exist that will let me get the count for a particular section?
- The topic ‘How to get count of settings set within a Customizer section?’ is closed to new replies.