最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin9PV0评论

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:

Post a comment

comment list (0)

  1. No comments so far