Can a page contain php code?

You can’t use PHP in the WordPress back-end editor. Maybe with a plugin you can, but not out of the box. The easiest solution for this is creating a shortcode. Then you can use something like [input type=”text” name”from”] in your editor. function input_func( $atts ) { extract( shortcode_atts( array( ‘type’ => ‘text’, ‘name’ => … Read more

Echo title attribute php

Not exactly wordpress question, more of a php but – The syntax for echo is quit simple : You start with a quotation mark, and close with a quotation mark. But since INSIDE the HTML we also need quotation marks , we separate them by using the single ‘ for PHP and the double ” … Read more

persist a variable set in header.php all the way down to footer.php

You’d have to declare it first above those includes and globalize it within header or footer before getting or setting the value. however- in the specific context you’re speaking of- getting a custom field value, it’s only retrieved from the database on the first call, then cached, so subsequent calls won’t hit the database again.

Where is this function’s callback getting its arguments from?

If you have a look at function do_meta_boxes() in wp-admin/includes/template.php then you’ll see this line close to the end of the function: call_user_func($box[‘callback’], $object, $box); That calls the callback function and provides the two arguments. The $box argument holds all the information about the metabox, like ID, title, callback function. In wp-admin/edit-form-advanced.php, which displays your … Read more

Security updates to 3.3.2

Since WP 3.1.3 has come out, we’ve released: 3.1.4 – security update 3.2 3.2.1 – security update 3.3 3.3.1 – security update 3.3.2 – security update On a scale of 1-10, skipping a single security update is about a 3 (bad, but not catastrophic). Skipping 4 security updates, though, would be closer to an 8-9 … Read more

Hide a div to subscribers(user role) in one page (is_page)

Just hiding a div is insecure – they can easily unhide it by editing the source or executing some Javascript in the browser’s URL bar. I believe this may be what you’re looking for: <?php if (current_user_can(‘subscriber’)){ ?> [html here] <?php } ?> Source: How to Use WordPress to Display Content Depending on a User’s … Read more

Force Users To Relogin

The wp_logout function will log a user out. Here’s an example that will log someone out and redirect to the login page when the url contains the query string ?my_logout_flag: add_action(‘init’, ‘wpse52743_check_logout’); function wpse52743_check_logout(){ if( isset( $_GET[‘my_logout_flag’] ) ) { wp_logout(); wp_redirect( wp_login_url() ); } }