I have an org file tracking my tasks across various projects:


* Job 1
** Tasks
*** TODO rewrite frontend in coldfusion
* Job 2
** Tasks
*** TODO Convince boss to buy stadium

I can do an org-capture-template to capture tasks to work.org's Job 1 header or Job 2 header, but what about Job 1 > Tasks, and same for Job 2?

For example:

  (setq org-capture-templates
          ("j" "Job 1" entry (file+headline ,(concat org-directory "/work.org") "Job 1")
           "* TODO %? \n"))

I tried, in place of "Job 1," "Job 1 Tasks," but that created a new top-level headline called "Job 1 Tasks." Based on a somewhat unrelated stackoverflow answer, I tried "*Job 1 Tasks", but again, that just created a new top-level headline.

How can I refer to a sub-header in an org-capture-template?

  • I haven't checked but I don't think you can do that: it will search for a headline, so the matcher must say e.g. "Tasks", but it's not possible to disambiguate the first Tasks from the second. But I may be wrong.
    – NickD
    Commented Mar 30, 2022 at 3:51
  • I was wrong: file+olp, as @TianshuWang points out in his answer, does the trick.
    – NickD
    Commented Mar 31, 2022 at 14:31

1 Answer 1


You can use file+olp like:

(setq org-capture-templates
      ("j" "Job 1" entry (file+olp ,(concat org-directory "/work.org") "Job 1" "Works")
       "* TODO %? \n"))

For more details, please refer to the doc of org-capture-templates through C-h v org-capture-templates.

  • I forgot about file+olp ...
    – NickD
    Commented Mar 31, 2022 at 14:29
  • I thought it might be necessary to use file+function and write you own function to prompt and find the right location. Commented Jan 18, 2023 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.