Skip to content

Remember Variable Scope

I’ve seen a few posts/questions asking why code from Theme X doesn’t work in a Carrington based theme. In some cases, the answer is fairly simple – the code is relying on global variables that aren’t available in the Carrington template being referenced.

The Carrington framework loads in template files within function calls, so if you need to access a global variable, you need to declare it as global first.

For example:

echo $post->post_author;

might not work in a certain template, but this should:

global $post;
echo $post->post_author;

Categories: Development.

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.

← Exit Carrington Text Preview