0

So I'm using this code to change Posts to a 'Mentor Q&A' as label however the function is returning a strange error

Parse error: syntax error, unexpected '$menu' (T_VARIABLE) ...

This is the function i'm trying to run:

function change_post_label() {
    global $menu;
    global $submenu;
    $menu[5][0] = 'Mentor Q&A';
    $submenu['edit.php'][5][0] = 'Mentor Q&A';
    $submenu['edit.php'][10][0] = 'Add Mentor Q&A';
    $submenu['edit.php'][16][0] = 'Mentor Q&A Tags';
    echo '';

function  change_post_object() {
    global $wp_post_types;
    $labels = &$wp_post_types['post']->labels;
    $labels->name = 'Mentor Q&A';
    $labels->singular_name = 'Mentor Q&A';
    $labels->add_new = 'Add Mentor Q&A';
    $labels->add_new_item = 'Add Mentor Q&A';
    $labels->edit_item = 'Edit Mentor Q&A';
    $labels->new_item = 'Mentor Q&A';
    $labels->view_item = 'View Mentor Q&A';
    $labels->search_items = 'Search Mentor Q&A';
    $labels->not_found = 'No Mentor Q&A found';
    $labels->not_found_in_trash = 'No Mentor Q&A found in Trash';
    $labels->all_items = 'All Mentor Q&A';
    $labels->menu_name = 'Mentor Q&A';
    $labels->name_admin_bar = 'Mentor Q&A';
}
 
add_action( 'admin_menu', 'change_post_label' );
add_action( 'init', 'change_post_object');

This function is also being called in the functions.php of a child theme, I'm not sure if that has anything to do with it.

joshy
  • 60
  • 8

2 Answers2

0

I feel function should be closed properly

function change_post_label() {
  global $menu;
  global $submenu;
  $menu[5][0] = 'Mentor Q&A';
  $submenu['edit.php'][5][0] = 'Mentor Q&A';
  $submenu['edit.php'][10][0] = 'Add Mentor Q&A';
  $submenu['edit.php'][16][0] = 'Mentor Q&A Tags';
  echo '';
}
Ram Sharma
  • 8,676
  • 7
  • 43
  • 56
0

Solved. The issue was that the indents in the code I copied if from were actual spaces making the code invalid, doh!

Lesson Learned.

joshy
  • 60
  • 8