• Resolved kzoo

    (@kzoo)


    This may have a simple answer but I would like to store all the variables I’ve declared ( or cached ) across my theme in a central file and serve then this file globally ( Similar to how get_header(), get_footer() and get_sidebar() works ).

    For this particular project, it would be more convenient if the multitude of variables I’ve created across my theme were housed in a central location in lieu of being scattered throughout various theme files.

    I’ve tried creating a file called variables.php and serving it via get_template_part but without success.

    Is there a idiomatic way of accomplishing this in WordPress?

Viewing 3 replies - 1 through 3 (of 3 total)
  • catacaustic

    (@catacaustic)

    A “better” way that I’d suggest doing that is to save the values using update_option() and get the values when ever you need them with get_option(). That way everything stored in the database, and you can access it anywhere that you need to without adding in any extra files or code.

    Thread Starter kzoo

    (@kzoo)

    This is amazing.
    Thanks @catacaustic
    I’ll definitely get a lot of use out of this.

    Thread Starter kzoo

    (@kzoo)

    This is resolved.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Is There a Way to Create a Global Variable Repository’ is closed to new replies.