0

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

work.org

* 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?

2
  • 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
    Mar 30 at 3:51
  • I was wrong: file+olp, as @TianshuWang points out in his answer, does the trick.
    – NickD
    Mar 31 at 14:31

1 Answer 1

3

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.

1
  • I forgot about file+olp ...
    – NickD
    Mar 31 at 14:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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