Get entry index - structure not channel I want to display the current entry's index - like in this post Get entry index.

However my entries are in a structure section type not a channel, so they are not ordered by date.

Is is possible to edit the solution (below) from the above post so that it is not sorting the entries by date but rather retaining the custom order of the structure?

{# Get this entry + all entries posted before it #}
{% set postDateParam = '&lt;= ' ~ entry.postDate|date('c') %}
{% set entryIds = craft.entries.section('news')
  .order('postDate asc').postDate(postDateParam).ids() %}

{# Count them #}
{% set position = entryIds|length %}

{{ position }}
I found the clue for how to do this in the getPrevSibling documentation:


  getPrevSibling() will return the previous sibling whether or not it’s enabled. If you want to get the closest enabled sibling, you can do this instead:
  
  {% set prevSibling = craft.entries.positionedBefore(entry).order('lft desc').first() %}


So this query will get the number of enabled previous siblings:

{% set prevSibsCount = craft.entries.positionedBefore(entry).total() %}


And then your position will be that + 1:

{% set position = prevSibsCount + 1 %}
{{ position }}