I'm new with WP so I need advice. I'm workig on plugin where is required adding some new atrributes to selected div or paragraph.

Is there any way how to get html tag (DOM) IDs from current template? not "current_template_id" ;)

I would like to make list or array in plugin option page at admin side, where users be able select div or paragraph by id or class and give them new atrributes.

I haven't code any yet. It's a purely theoretical question, which methods and functions use.

  • If you're more specific about what you're trying to do, people may be able to give you better and more targeted advice. There are some (not many) cases where it's easy(er?) to filter markup.
    – mrwweb
    Mar 30, 2015 at 18:56

1 Answer 1


WordPress doesn't operate with DOM for the purpose of page source generation from templates. Templates are treated and run as PHP source files, producing any and all output.

Unless you have control over actual templates your options likely are:

  1. Attempting to buffer and rewrite output (rather fragile, more so for publicly released plugin)
  2. Adjust markup with JavaScript client–side on already generated page source
  • Well, can I reach markup from "Option page" in wp-admin? Can't, I think.
    – Jayme
    Mar 30, 2015 at 16:21
  • @Jayme that's a little fuzzy question... You should edit your question with more details about which part of WP precisely you need to target and how.
    – Rarst
    Mar 30, 2015 at 16:27
  • Wat? Ok, in my plugin which has control in Setting at admin side I need to get list/array all IDs in divs and paragraphs from current template for site.
    – Jayme
    Mar 30, 2015 at 16:50

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.