So, yes, WP can be quite a mess, more so in complicated themes. Some of it is just experience and chewing through sources.
There are, however, several things that can help to determine what is happening via code:
- Dumping
get_included_files()
will get you all PHP files loaded up to that point. It’s messy, but sometimes it’s what it takes. - There are plugins like What The File that will give a little more now picture of template files involved.
- You can dump
wp_debug_backtrace_summary()
to see execution stack to a specific point in code. - Sometimes hooks are more important than files, you can use helpers like R_Debug to dump live hooks execution and see what fires.