Can you keep session data for visitors?

I would recommend using $_GET or $_POST variables … the same way you submit the form. This has nothing to do with session. Basically, when the user fills out the form, you’re populating $_POST with information. When the user submits the form, you process the information in $_POST and display a thank you page … … Read more

Use to track referrals

Try using add_query_arg(). For example, if your query key is “ref”, and your query key value is “AFFILIATEID”: <?php add_query_arg( ‘ref’, ‘AFFILIATEID’ ); ?> If you need to retrieve your query arg value, use get_query_var(): <?php get_query_var( ‘ref’ ); ?>

Variable scope producing undefined variable notices in included files

I have found the answer in another thread. Passing variables through locate_template Essentially the WordPress function get_template_part changes the scope of the variable $user_choice. PHP default behaviour when using include() is that the variable from the current script is still available in the included file. However because get_template_part() is a function any variables in that … Read more

Replacing string with a variable in php

There are 4 valid ways of defining a string, see this question for more details. However in your case there is a special exception provided by PHP. Most users are unaware of it however, and it does leave ambiguities, as it’s no longer possible to tell a string literal, a constant, or a define apart, … Read more

How to pass data around?

I have different menu items. When the user clicks on a menu item, I want them to go to a particular destination. Each menu’s destination has a different background color. When you say destination I assume you mean page or post. If you use WordPress’s built in body class and post class you can target … Read more

Print string to footer using wp_footer option

Do you have to use a variable for you script? I have done this in the past and has worked… // add script to the footer and break out of PHP function slider_option(){ ?> <script>script function data</script> <?php } ?> add_action(‘wp_footer’,’slider_option’); If this does not work make sure you have the footer hook in you … Read more

What is the $current_screen global variable?

$current_screen is a global variable in admin screens. It holds the result of WP_Screen::get( $hook_name )->set_current_screen();. WP_Screen is a class, get() is a static method that returns a real object – an instance of WP_Screen with some predefined properties: $screen->base = $base; $screen->action = $action; $screen->post_type = (string) $post_type; $screen->taxonomy = (string) $taxonomy; $screen->is_user = … Read more