Sorting Custom Post Type Loop by Post Author ID of current post

Hi
I have two CPT “companies” and “documents” a company may have multiple documents.
On the single view of a specific company it has a list of the documents, what I am trying to do is filter the loop of the documents by author_id. As author_id would be the same for the company and documents.

<Loop type=document count=-1 orderby=date order=desc 
      author=author_id>
    <li>
      <a href="{Field url}"><Field title /></a>
    </li>
  </Loop>

but it just won’t work in the precious plugin there was a variable called same and this does not work I have tried numerous ways with no joy.
If I manually put in the author_id say the number 3 (The author id) it works.

Please could someone help
thanks

If the author ID should be the same as the current post, something like this could work:

<Loop type=document author="{Field author_id}" orderby=date order=desc>

If not, we’ll need to figure out how to get the author ID, then pass it to the author attribute.


There’s author=current, which means the author should be the current user, but that’s probably not what you need.

Thanks, Eliot for the help.
I had been trying
{Field author_id}
with no joy, I just noticed the quotes around the attribute.
So creating
"{Field author_id}"
Worked
Thanks

1 Like

Ah, I see - someone else recently had the same issue with tag attributes and “quotes”. I’ll try to improve the documentation about it.