WordPress Related Plugin – only show when related content

I don’t know for sure if this would work but this is where I’d start: <?php $related_content = $related->show(get_the_ID()); ?> <?php if($related_content): ?> <div class=”related”><strong>Related products</strong><br /> <?php echo $related_content; ?> </div> <?php endif; ?>

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() ); } }