Redirecting, I am building a banner plugin. So I started the custom post type (man i love custom post types) and just building the page. For a banner we need redirecting. So i found a lively function called wp_redirect.
Building on. A custom page, adding a widget for the banner. Linking to the banner with the the_permalink function. Getting to the page. Setting up the the_content. And redirecting….. header already sent. Of course, we are in the middle of my wordpress page setting up the content. Now the dilemma, where can we put an action before the page is being loaded and knowing the post and type.
Scanning through the wordpress codex finding little wich i can use, so I just started to read through the code starting at index.php. Couple of files further along i am happy to find a little file called template-loader.php wich has an action in it. So i checked the setup for the action.
In the action i check if there is output on the screen, no there is not. Cool. Now global that post and check if we have a winner.
global $post; print_r($post);
No need in telling the result, couse this is where i found my answer. I have my post and know my redirect using some get_post_meta. Redirect to my meta, save my banner click in the database in my own table. Done.
Did use my maby_imagerese function again. Custom image sizes rule.