Meta tags:
description= template_redirect is a popular WordPress hook, for good reason. When it runs, WordPress has made its main query. All objects have been instantiated, but no output has been sent to the browser. It is your last stop to hook in and redirect the user somewhere else, and the best place to do so if you…;
Headings (most frequently used words):
on, wordpress, mark, about, don, use, template_redirect, to, load, an, alternative, template, file, post, navigation, thoughts, share, this, related, leave, comment, cancel, reply,
Text of the page (most frequently used words):
wordpress (15), this (9), mark (9), for (8), the (6), #template_redirect (5), code (4), my_callback (4), file (4), and (4), alternative (4), template (4), com (3), other (3), jaquith (3), share (3), but (3), load (3), hook (3), post (2), content (2), log (2), sign (2), subscribed (2), subscribe (2), have (2), comment (2), blog (2), anything (2), loading (2), like (2), facebook (2), opens (2), new (2), window (2), template_ (2), include (2), redirect (2), with (2), template_include (2), function (2), original_template (2), some_condition (2), return (2), some_path (2), some (2), custom (2), php (2), else (2), that (2), lead (2), you (2), good (2), has (2), all (2), objects (2), been (2), don (2), use (2), services (2), menu (2), collapse, bar, manage, subscriptions, view, reader, report, copy, shortlink, privacy, already, account, now, join, 053, subscribers, reblog, create, website, leave, cancel, reply, ask, six, apart, suspends, movable, type, open, source, project, navigation, february, 2014, related, includes, redirects, same, effect, doesn, interfere, plugin, theme, distinction, should, easy, remember, add_filter, problem, hooked, isn, going, run, can, break, sites, very, odd, bugs, want, there, filter, after, add_action, exit, see, lot, popular, reason, when, runs, made, its, main, query, instantiated, output, sent, browser, your, last, stop, user, somewhere, best, place, need, full, knowledge, queried, what, not, twitter, consulting, tempus, fugit, things, digital, hub, links, online, presences, markjaquith, provider, personal, publishing, platform, developer, freelance, about, home, close, search, thoughts, primary, skip,
Text of the page (random words):
don t use template_redirect to load an alternative template file mark on wordpress skip to content primary menu mark on wordpress thoughts on wordpress search for close menu home wordpress services about hi i m mark jaquith a provider of freelance wordpress services and a lead developer of the wordpress personal publishing platform this is my blog for all things wordpress go to my digital hub at markjaquith com for links to my other online presences mark jaquith tempus fugit mark on wordpress wordpress consulting twitter don t use template_redirect to load an alternative template file template_redirect is a popular wordpress hook for good reason when it runs wordpress has made its main query all objects have been instantiated but no output has been sent to the browser it is your last stop to hook in and redirect the user somewhere else and the best place to do so if you need full knowledge of the queried objects but what it is not good for is loading an alternative template i see code like this a lot add_action template_redirect my_callback function my_callback if some_condition include some_path some custom file php exit the problem with this code is that anything hooked in to template_redirect after this code isn t going to run this can break sites and lead to very odd bugs if you want to load an alternative template there s a filter hook for that template_include add_filter template_include my_callback function my_callback original_template if some_condition return some_path some custom file php else return original_template same effect but doesn t interfere with other plugin or theme code this distinction should be easy to remember template_ redirect is for redirects template_ include is for includes share this share on x opens in new window x share on facebook opens in new window facebook like loading related february 19 2014 mark jaquith post navigation six apart suspends movable type open source project ask mark anything leave a comment cancel reply δ create a website or blog at wordpress com comment reblog subscribe subscribed mark on wordpress join 1 053 other subscribers sign me up already have a wordpress com account log in now privacy mark on wordpress subscribe subscribed sign up log in copy shortlink report this content view post in reader manage subscriptions collapse this bar d
|