Can’t get options with $data[‘variable’]

This is actually a PHP question, and not a WordPress question. The issue is that global variables don’t pass through the include()/require() call from the template file into header.php. The solution is to define $data after you globalize it. Without knowing your options framework or your Theme specifically, I can only answer in general terms; … Read more

Shortcode not passing variable to included file

Ok, so somehow I got it working by changing it to this: It looks like it didn’t like ‘the_clientId’. Maybe it just doesn’t like capital letters???? [insert-form form_location=”form.php” identification_number=”12345″] function insert_the_form($atts){ $form_base = plugin_dir_path(__DIR__); // Shortcode attributes & options $atts = shortcode_atts( array( ‘form_location’ => ‘NULL’, ‘identification_number’ => ‘NULL’ //Variable for client ID ), $atts, … Read more

Get attachment if matches a variable

$attachments holds array of posts, you are missing something like: $attachment = $attachments[0]; or foreach( $attachments as $attachment ) Update Nope, like this: foreach( $attachments as $attachment ) if ($attachment->post_title == $programme) { echo the_attachment_link($post->ID, false); break; }

If I define a variable in header.php, how do I make it available to templates?

It the template is called via get_template_part(), then it is in a new variable scope. to access it, you have to use the global keyword in you template file: global $foo; echo $foo; As header.php probalbly is also called in a function scope, you have to make sure there the variable is used in global … Read more