Drupal 6: Creating a menu item with a dynamic title

In this code snippet I'll explain how to create a menu item that has a dynamic title.

<?php
// define hook_menu to create menu item
function MYMODULE_menu() {
  $items = array();

  $items['MY/PAGE/URL/%'] = array(
    'page callback' => 'MY_PAGE_CALLBACK_FUNCTION',
    'title callback' => 'MY_PAGE_CALLBACK_TITLE_FUNCTION',
    'title arguments' => array(3),
    'type' => MENU_CALLBACK,
  );

  return $items;
}

// define title callback function
function MY_PAGE_CALLBACK_TITLE_FUNCTION($arg) {
  return "My dynamic title: " . $arg;
}
?>

In the above example, if you browsed to the URL: MY/PAGE/URL/blah-blah-blah, you'd have a page title of: My dynamic title blah-blah-blah. In a more applicable example, you might need to pass the node id to the callback function and then return: $node->title;

Check out the documentation on wildcard loader arguments for more advanced options.