How to Change Order When Programatically Writing Out OptionList Attribute


If I get an Option List attribute and write out it’s values like this, how do I change the order to Display Order? It seems like it is writing out in order of “most recently added value last”?

$projectServices = $page->getAttribute('project_services');

foreach($projectServices as $service) {
  echo $service . '<br />';

Hi @madesimplemedia - just looking here - it looksl ike there’s a “display” parameter but not sure if that would make any difference for an option list? Maybe? Give it a shot and let me know if it works.

Hi @EvanCooper Thanks for the idea. I tried this which doesn’t error, but also doesn’t change the order either:

$projectServices = $page->getAttribute('project_services', 'alpha_asc');

Hmm yeah - that seems like it might be a core bug if it’s not honoring the display order, you might consider making a Github issue for it:

Thanks, I have now done that.