customization - Change meta-box title- "LearnDash Quiz Settings" to "Quiz Settings"

admin2025-06-06  3

I want to change a meta-box title on the create question page from- "LearnDash Quiz Settings" to "Quiz Settings" on create question page.

I have seen a few posts that explain changing custom posts meta titles but no luck here.

I am attempting to add the changes to a MU custom functions plugin, rather than the theme's functions.php file.

I am admittedly lost on how to do this and have been messing with variations of the following code. newbness ahead... here's a img link illustrating what I'm trying to do.

The following code changes the title from LearnDash Question Settings metabox title to Question Settings

add_action('do_meta_boxes', 'my_customize_meta_boxes'); //using do_meta_boxes also allows plugin metaboxes to be modified
function my_customize_meta_boxes(){
  $post_types = get_post_types();
  remove_meta_box( 'sfwd-question_quiz', $post_types, 'normal' );
  add_meta_box('sfwd-question_quiz', __('Quiz Question Settings'), '', $post_types, 'side', 'default', 'sfwd-question');
}

The following code is used to get this to work with your custom meta's

add_action('add_meta_boxes', 'change_meta_box_titles', 999);
function change_meta_box_titles() {
    global $wp_meta_boxes; // array of defined meta boxes
    // cycle through the array, change the titles you want

unset( $wp_meta_boxes ['post']['side']['core']['sfwd-question_quiz']
);
add_meta_box('sfwd-question_quiz',
__('Quiz Question Settings'),

EDIT: @karpstrucking Here is the image you requested. sry for delay.

I want to change a meta-box title on the create question page from- "LearnDash Quiz Settings" to "Quiz Settings" on create question page.

I have seen a few posts that explain changing custom posts meta titles but no luck here.

I am attempting to add the changes to a MU custom functions plugin, rather than the theme's functions.php file.

I am admittedly lost on how to do this and have been messing with variations of the following code. newbness ahead... here's a img link illustrating what I'm trying to do. http://take.ms/evyiL

The following code changes the title from LearnDash Question Settings metabox title to Question Settings

add_action('do_meta_boxes', 'my_customize_meta_boxes'); //using do_meta_boxes also allows plugin metaboxes to be modified
function my_customize_meta_boxes(){
  $post_types = get_post_types();
  remove_meta_box( 'sfwd-question_quiz', $post_types, 'normal' );
  add_meta_box('sfwd-question_quiz', __('Quiz Question Settings'), '', $post_types, 'side', 'default', 'sfwd-question');
}

The following code is used to get this to work with your custom meta's

add_action('add_meta_boxes', 'change_meta_box_titles', 999);
function change_meta_box_titles() {
    global $wp_meta_boxes; // array of defined meta boxes
    // cycle through the array, change the titles you want

unset( $wp_meta_boxes ['post']['side']['core']['sfwd-question_quiz']
);
add_meta_box('sfwd-question_quiz',
__('Quiz Question Settings'),

EDIT: @karpstrucking Here is the image you requested. sry for delay.

Share Improve this question edited Nov 28, 2018 at 7:57 vayderr asked Nov 22, 2018 at 4:33 vayderrvayderr 14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can do this via the available translation filters:

add_filter( 'gettext_with_context', 'gowp_replace_learndash_label', 10, 4 );
function gowp_replace_learndash_label( $translation, $text, $context, $domain ) {
    if (
        ( 'LearnDash %s Settings' == $text ) &&
        ( 'placeholder: Quiz' == $context ) &&
        ( 'learndash' == $domain )
    ) {
        $translation = str_replace( 'LearnDash ', '', $translation );
    }
    return $translation;
}

This removes "LearnDash " from the string:

You can also remove the first condition of the if-check to have this removed from all of the metaboxes:

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749146537a316761.html

最新回复(0)