Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm missing something here:

function page_help($contextual_help, $screen_id, $screen) {

if ($screen_id == 'page') {

    $contextual_help = '
    <h5>Shortcodes</h5>
    <p>Shortcodes help</p>
    '.$contextual_help;

    return $contextual_help;
}

elseif ($screen_id == 'post') {

    $contextual_help = '
    <h5>Post help</h5>
    <p>Help is on its way!</p>
    '.$contextual_help;

    return $contextual_help;
}
}       

add_filter('contextual_help', 'page_help', 10, 3);

The code is inserting into the correct screens but I am having two issues:

  1. The code is inserting at the top, I'd like it at the bottom.

  2. The code is deleting the help from all other screens except those mentioned above.

Thanks in advance for your tips!

Niels

share|improve this question

1 Answer 1

up vote 0 down vote accepted

In order to not delete help from all other screens, you need to always return the contextual help text, otherwise your filter doesn't return anything for non-page/post screens and so nothing will show up. Move the return to the bottom of the function, outside of your if/else. Also, the original contextual help is being concatenated to the end of your custom message, so move it to the front to have your text put at the bottom. Thus:

function myprefix_page_help($contextual_help, $screen_id, $screen) {

  if ($screen_id == 'page') {
    $contextual_help = $contextual_help.'
    <h5>Shortcodes</h5>
    <p>Shortcodes help</p>';
  }

  elseif ($screen_id == 'post') {
    $contextual_help = $contextual_help.'
    <h5>Post help</h5>
    <p>Help is on its way!</p>';
  }

  return $contextual_help;
}       

add_filter('contextual_help', 'myprefix_page_help', 10, 3);
share|improve this answer
    
Hey thanks @helenyhou!!!! And you even helped me understand more about WP! –  Niels Jun 20 '11 at 5:50
    
Oops! Spoke too soon. Its failing for some reason... –  Niels Jun 20 '11 at 6:00
    
@Niels Oeltjen What exactly is failing? Are you getting an error message? I didn't test the code, so it's possible that I have a typo in there. Also, you should always prefix your functions to prevent collisions and I forgot to do so above, so I will edit my answer to reflect that. –  helenhousandi Jun 20 '11 at 12:02
    
Sorry @helenyhou, it was a simple issue in the end: clashing plugin that I neglected to turn off. I discovered the clash by applying namespacing to find that page_help was running in that plugin (by sheer coincidence). Funnily enough though, no error reporting... –  Niels Jun 21 '11 at 3:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.