Pods: add option to change "More Fields" metabox title

Created on 4 Nov 2012  ·  7Comments  ·  Source: pods-framework/pods

How can I change the "More Fields" text?

Enhancement

All 7 comments

Use the new 'pods_meta_default_box_title' filter

Ok.

So

add_filter('pods_meta_default_box_title','changethatname');

function changethatname($value) {
$value = 'Dancer Details';
return $value;
}

for example, works.

How can we modify the above to specify different default box titles for different Pods?

srikat - you probably worked this out already but I hope someone else finds this useful:

add_filter('pods_meta_default_box_title','changethatname',10,5);
/* See http://codex.wordpress.org/Function_Reference/add_filter */

function changethatname($title, $pod, $fields, $type, $name ) {

  // assuming we are changing the meta box title on a pod named 'page' 
  $title = ($name=='page') ? __('My Meta box title', 'plugin_lang') : $title ;

  return $title;
}

What would be the code to change the meta titles for multiple post types?

@jaycollier

add_filter( 'pods_meta_default_box_title', 'my_change_pods_metabox_title', 10, 5 );

/**
 * Filter the title of the Pods metabox for multiple post types.
 *
 * @param string   $title  The title to use, default is 'More Fields'.
 * @param obj|Pods $pod    Current Pods Object.
 * @param array    $fields List of fields that will go in the metabox.
 * @param string   $type   The type of Pod.
 * @param string   $name   Name of the Pod.
 *
 * @return string The title for the metabox.
 *
 * @since unknown
 */
function my_change_pods_metabox_title( $title, $pod, $fields, $type, $name ) {
    $post_types_to_change = [
        'my_custom_post_type',
        'post',
        'page',
    ];

    if ( ! in_array( $name, $post_types_to_change, true ) ) {
        return $title;
    }

    return 'My custom title';
}

cc @jimtrue

Thank you! I was imagining different titles for different post types, but this will be good!

Was this page helpful?
0 / 5 - 0 ratings