003_TF_Where-Your-Code-Should-Be-LocatedWhen using Titan Framework, there are two types of code that you write:

  • Creating stuff (options, admin pages, etc.)
  • Getting option values

The placement of your code for these types are different. This is important since getting option values in the wrong location can lead you to get null values.

Just remember these two rules:

  1. Every time you create stuff: put your code in your functions.php for themes or put them in your main plugin file. All your creation code should be inside the tf_create_options hook.Every time you get option values, put your code inside your theme template files – such as page.php, single.php, etc, or put your code in a function that runs during or after the after_setup_theme hook – such as wp_head, wp_footer, etc.
  2. Every time you get option values: put your code inside your theme template files – such as page.php, single.php, etc, or put your code in a function that runs during or after the after_setup_theme hook – such as wp_head, wp_footer, etc.

Refer to the Getting Started guide for more information on this.

Leave a Reply