SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Change Title Of Meta Boxes?

    I'm trying to create a function that would allow me to change the title of an established meta box (i.e, change Meta Box title 'Authors' to 'Team', etc.)

    I didn't want to use JS or have to unset the original meta box and re-add it.

    I started off with the following:

    PHP Code:
    // hook to the 'add_meta_boxes' action
    add_action('add_meta_boxes''change_meta_box_titles');
    function 
    change_meta_box_titles($post_type$post)) {
        global 
    $wp_meta_boxes// array of defined meta boxes
        // cycle through the array, change the titles you want

    I'm stuck on the part to "cycle through the array and change the titles you want". What would be the best way to accomplish this? Using a foreach to loop? Or a Switch/Case scenario? Could anyone possibly give me an example of how to accomplish this?

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Ryan B | My Blog | Twitter

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    Thanks for the suggestion, but not what I was looking to do(I already know how to create meta's and custom fields). I wanted to change the Title of pre-existing boxes.

    I found a semi-solution for this. The following will allow you to change the titles of "Core Meta Boxes" but for some reason won't work with custom meta boxes:

    PHP Code:
    //hook to the 'add_meta_boxes' action
    add_action('add_meta_boxes''change_meta_box_titles');
    function 
    change_meta_box_titles() {
        global 
    $wp_meta_boxes// array of defined meta boxes
        // cycle through the array, change the titles you want
        
    $wp_meta_boxes['post']['normal']['core']['authordiv']['title']= 'Team Member';

    An example of a custom meta (using a custom post type) not working, that I mentioned above would be:

    PHP Code:
    $wp_meta_boxes['portfolio']['side']['high']['cc_projectinfo_meta']['title']= 'A New Title'
    In theory the above should work, but it doesn't.

  4. #4
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,659
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    The reason I suggested the plug in, was two reasons:
    1. Depending where you are putting the solution code, may cause some frustration, such as if you store it in a theme and change themes.
    2. While I didn't study the a plugin in detail, it looks like it collects all custom fields. Which would save energy down the road or if you did #1
    Ryan B | My Blog | Twitter


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •