Welcome, guest!

Feel free to read the blog, browse for themes, or join the club.

Meta-box array type-select

  1. Hi,

    If I want to put a select input in a meta-box on the edit page of my child theme, how can I add it to the array? I see that the code will process the input type select, but I can't seem to be able to format the string correctly.

    For example,
    $arr = array(something);

    Where does it go in

    $transform = array(
    		'something' => array( 'name' => 'Something', 'title' => __('Something:', 'transformation'), 'type' => 'select' ), );
    }
  2. This may help you, thanks to Justin

    Meta-box array type-select

  3. Hi,

    I'm trying that, but the select box shows up empty :(

    Vidyut

  4. You must be a logged-in exclusive member to view this reply.

  5. add_filter( 'hybrid_page_meta_boxes', 'trans_page_cat' );
    
    function trans_page_cat( $meta ) {
    $categories=get_category_list();
    $meta['transcat'] = array( 'name' => 'Trans_Category', 'title' => __('Attach Category: Excerpts from this category will appear under the page content', 'transformation'),'type' => 'select', 'options' => $categories );
    return $meta ;
    	}
    
    function get_category_list() {
    $catg = get_categories();
    return $catg;
    }

    It gives me a fatal error Object of class stdClass could not be converted into string...

    There is other stuff there - text input which works perfectly.

  6. You must be a logged-in exclusive member to view this reply.

  7. oh. If I want to have a select box with categories out of which one can be selected, what would I have to use?

  8. I tried wp_list_categories() but that outputs links outside the select box...

  9. I think you might be looking for something like:

    $catg = get_categories();
    $myarray = array();
    foreach ($catg as $cat) {
      $myarray[] = $cat->cat_name;
    }
    return $myarray;

    which should give you an array of category names if this is what you are after.

  10. That works just perfect. Thank you.

    Vidyut

  11. You must be a logged-in exclusive member to view this reply.

  12. okay.

    If I want to display the category name in the drop down box, but use save the term_id to prevent problems, how do I go about doing it?

    Curently I have:

    $categories=get_category_list();
    if ( is_array( $categories ) ) $meta['transcat'] = array( 'name' => 'Trans_Category', 'title' => __('Attach Category: Excerpts from this category will appear under the page content', 'transformation'),'type' => 'select', 'options' => $categories );

    and

    function get_category_list() {
    $catg = get_categories();
    $myarray = array();
    foreach ($catg as $cat) {
      $myarray[] = $cat->cat_name;
    }
    return $myarray; }
  13. You must be a logged-in exclusive member to view this reply.

  14. Hi,

    I'm using 0.8 now. Can you help me with the code I will have to use to achieve this?

    Also, for some reason, my meta box has stopped saving. I'm using the same code.

    Vidyut

  15. You must be a logged-in exclusive member to view this reply.

  16. I don't have or know how to use svn. Is there any other way I can get the recent revision? Or should I wait for the release?

  17. You must be a logged-in exclusive member to view this reply.

Reply

You must log in to post.

Limited Access

If you have an account, please take a moment to log in.

Non-exclusive members have limited access to the support forums.

To enjoy the full range of support, sign up for an exclusive membership in the theme club.

Support Forums

  • Core Framework (55 posts)
  • Hybrid Theme (22,711 posts)
  • Bliss Theme (255 posts)
  • Options Theme (10,362 posts)
  • Visionary Theme (767 posts)
  • WordPress (144 posts)
  • WordPress Plugins (2,146 posts)
  • bbPress Themes (308 posts)
  • General Discussion (5,572 posts)
  • Critical Theme (0 posts)
  • Hybrid News Theme (132 posts)
  • Hybrid Original Theme (26 posts)
  • Leviathan Theme (16 posts)
  • Life Collage Theme (10 posts)
  • Old School Theme (3 posts)
  • Outline Theme (108 posts)
  • Skeleton Theme (40 posts)
  • Structure Theme (2,768 posts)
  • Members Plugin (2 posts)
  • Cleaner Gallery Plugin (14 posts)
  • Get the Image Plugin (3 posts)
  • Message Board Plugin (0 posts)
  • Widgets Reloaded Plugin (0 posts)
  • Breadcrumb Trail Plugin (0 posts)
  • Query Posts Plugin (81 posts)
  • Hybrid Hook Plugin (7 posts)
  • Hybrid Hook Widgets Plugin (0 posts)
  • Hybrid Tabs (5 posts)