0

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. requested image of metas

1 Answer 1

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:

enter image description here

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

enter image description here

5
  • Thank you for your solution, it works almost completely on the Add New Quiz page's metaboxes. I have added the translation code you suggested. I'm curious though, why only the Quiz Builder metabox still says LearnDash. Also, there's another metabox on the page for a 3rd party plugin (memberpress) shown in this page-metaboxes image, how would that metabox title be changed to remove the word "MemberPress"? Thx for helping a newb in need ;)
    – vayderr
    Commented Nov 25, 2018 at 6:57
  • Can you add screenshots of the area that still says LearnDash and the metabox that you want MemberPress removed? Commented Nov 26, 2018 at 12:44
  • Still learning to format in here, can't get image to show like yours above but this is the link to the image showing the metaboxes in question. monosnap.com/direct/K0nCtB6gdGrY9g4k46Twaejqy231IF. Thank you!
    – vayderr
    Commented Nov 26, 2018 at 22:37
  • This link shows the particular setting that activates the builder which adds the metabox to the "add new quiz" page. monosnap.com/file/Lw4ACqEulvUk0RHar7OTydkZzA5Vjp
    – vayderr
    Commented Nov 26, 2018 at 22:46
  • PS- I think the v2.5.6 of learndash added a quiz builder feature that, when activated, adds the metabox that still says "LearnDash" into the add new quiz page. just fyi in case you don't see that meta on your page or wherever you're referencing. Thanks
    – vayderr
    Commented Nov 27, 2018 at 0:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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